@fluentui/react-charts 9.3.21 → 9.74.3-experimental.esm.20260709-49ee7a20cf.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (767) hide show
  1. package/CHANGELOG.md +20 -2
  2. package/package.json +15 -17
  3. package/dist/index.d.ts +0 -5724
  4. package/lib/AnnotationOnlyChart.js +0 -1
  5. package/lib/AnnotationOnlyChart.js.map +0 -1
  6. package/lib/AreaChart.js +0 -1
  7. package/lib/AreaChart.js.map +0 -1
  8. package/lib/CartesianChart.js +0 -1
  9. package/lib/CartesianChart.js.map +0 -1
  10. package/lib/ChartTable.js +0 -1
  11. package/lib/ChartTable.js.map +0 -1
  12. package/lib/DeclarativeChart.js +0 -1
  13. package/lib/DeclarativeChart.js.map +0 -1
  14. package/lib/DonutChart.js +0 -1
  15. package/lib/DonutChart.js.map +0 -1
  16. package/lib/FunnelChart.js +0 -1
  17. package/lib/FunnelChart.js.map +0 -1
  18. package/lib/GanttChart.js +0 -1
  19. package/lib/GanttChart.js.map +0 -1
  20. package/lib/GaugeChart.js +0 -1
  21. package/lib/GaugeChart.js.map +0 -1
  22. package/lib/GroupedVerticalBarChart.js +0 -1
  23. package/lib/GroupedVerticalBarChart.js.map +0 -1
  24. package/lib/HeatMapChart.js +0 -1
  25. package/lib/HeatMapChart.js.map +0 -1
  26. package/lib/HorizontalBarChart.js +0 -1
  27. package/lib/HorizontalBarChart.js.map +0 -1
  28. package/lib/HorizontalBarChartWithAxis.js +0 -1
  29. package/lib/HorizontalBarChartWithAxis.js.map +0 -1
  30. package/lib/Legends.js +0 -1
  31. package/lib/Legends.js.map +0 -1
  32. package/lib/LineChart.js +0 -1
  33. package/lib/LineChart.js.map +0 -1
  34. package/lib/PolarChart.js +0 -1
  35. package/lib/PolarChart.js.map +0 -1
  36. package/lib/Popover.js +0 -1
  37. package/lib/Popover.js.map +0 -1
  38. package/lib/ResponsiveContainer.js +0 -1
  39. package/lib/ResponsiveContainer.js.map +0 -1
  40. package/lib/SankeyChart.js +0 -1
  41. package/lib/SankeyChart.js.map +0 -1
  42. package/lib/ScatterChart.js +0 -1
  43. package/lib/ScatterChart.js.map +0 -1
  44. package/lib/Sparkline.js +0 -1
  45. package/lib/Sparkline.js.map +0 -1
  46. package/lib/VegaDeclarativeChart.js +0 -1
  47. package/lib/VegaDeclarativeChart.js.map +0 -1
  48. package/lib/VerticalBarChart.js +0 -1
  49. package/lib/VerticalBarChart.js.map +0 -1
  50. package/lib/VerticalStackedBarChart.js +0 -1
  51. package/lib/VerticalStackedBarChart.js.map +0 -1
  52. package/lib/components/AnnotationOnlyChart/AnnotationOnlyChart.js +0 -196
  53. package/lib/components/AnnotationOnlyChart/AnnotationOnlyChart.js.map +0 -1
  54. package/lib/components/AnnotationOnlyChart/AnnotationOnlyChart.types.js +0 -3
  55. package/lib/components/AnnotationOnlyChart/AnnotationOnlyChart.types.js.map +0 -1
  56. package/lib/components/AnnotationOnlyChart/index.js +0 -2
  57. package/lib/components/AnnotationOnlyChart/index.js.map +0 -1
  58. package/lib/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.js +0 -33
  59. package/lib/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.js.map +0 -1
  60. package/lib/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.raw.js +0 -24
  61. package/lib/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.raw.js.map +0 -1
  62. package/lib/components/AreaChart/AreaChart.js +0 -932
  63. package/lib/components/AreaChart/AreaChart.js.map +0 -1
  64. package/lib/components/AreaChart/AreaChart.types.js +0 -4
  65. package/lib/components/AreaChart/AreaChart.types.js.map +0 -1
  66. package/lib/components/AreaChart/index.js +0 -3
  67. package/lib/components/AreaChart/index.js.map +0 -1
  68. package/lib/components/AreaChart/useAreaChartStyles.styles.js +0 -63
  69. package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +0 -1
  70. package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js +0 -33
  71. package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js.map +0 -1
  72. package/lib/components/ChartTable/ChartTable.js +0 -160
  73. package/lib/components/ChartTable/ChartTable.js.map +0 -1
  74. package/lib/components/ChartTable/ChartTable.types.js +0 -4
  75. package/lib/components/ChartTable/ChartTable.types.js.map +0 -1
  76. package/lib/components/ChartTable/index.js +0 -3
  77. package/lib/components/ChartTable/index.js.map +0 -1
  78. package/lib/components/ChartTable/useChartTableStyles.styles.js +0 -136
  79. package/lib/components/ChartTable/useChartTableStyles.styles.js.map +0 -1
  80. package/lib/components/ChartTable/useChartTableStyles.styles.raw.js +0 -68
  81. package/lib/components/ChartTable/useChartTableStyles.styles.raw.js.map +0 -1
  82. package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.js +0 -659
  83. package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.js.map +0 -1
  84. package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js +0 -1
  85. package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js.map +0 -1
  86. package/lib/components/CommonComponents/Annotations/index.js +0 -2
  87. package/lib/components/CommonComponents/Annotations/index.js.map +0 -1
  88. package/lib/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.js +0 -223
  89. package/lib/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.js.map +0 -1
  90. package/lib/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.raw.js +0 -139
  91. package/lib/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.raw.js.map +0 -1
  92. package/lib/components/CommonComponents/CartesianChart.js +0 -665
  93. package/lib/components/CommonComponents/CartesianChart.js.map +0 -1
  94. package/lib/components/CommonComponents/CartesianChart.types.js +0 -2
  95. package/lib/components/CommonComponents/CartesianChart.types.js.map +0 -1
  96. package/lib/components/CommonComponents/ChartPopover.js +0 -197
  97. package/lib/components/CommonComponents/ChartPopover.js.map +0 -1
  98. package/lib/components/CommonComponents/ChartPopover.types.js +0 -1
  99. package/lib/components/CommonComponents/ChartPopover.types.js.map +0 -1
  100. package/lib/components/CommonComponents/index.js +0 -6
  101. package/lib/components/CommonComponents/index.js.map +0 -1
  102. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +0 -189
  103. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +0 -1
  104. package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +0 -131
  105. package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +0 -1
  106. package/lib/components/CommonComponents/useChartPopoverStyles.styles.js +0 -171
  107. package/lib/components/CommonComponents/useChartPopoverStyles.styles.js.map +0 -1
  108. package/lib/components/CommonComponents/useChartPopoverStyles.styles.raw.js +0 -127
  109. package/lib/components/CommonComponents/useChartPopoverStyles.styles.raw.js.map +0 -1
  110. package/lib/components/DeclarativeChart/DeclarativeChart.js +0 -397
  111. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +0 -1
  112. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +0 -163
  113. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +0 -1
  114. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +0 -3490
  115. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +0 -1
  116. package/lib/components/DeclarativeChart/index.js +0 -1
  117. package/lib/components/DeclarativeChart/index.js.map +0 -1
  118. package/lib/components/DonutChart/Arc/Arc.js +0 -118
  119. package/lib/components/DonutChart/Arc/Arc.js.map +0 -1
  120. package/lib/components/DonutChart/Arc/Arc.types.js +0 -1
  121. package/lib/components/DonutChart/Arc/Arc.types.js.map +0 -1
  122. package/lib/components/DonutChart/Arc/index.js +0 -2
  123. package/lib/components/DonutChart/Arc/index.js.map +0 -1
  124. package/lib/components/DonutChart/Arc/useArcStyles.styles.js +0 -80
  125. package/lib/components/DonutChart/Arc/useArcStyles.styles.js.map +0 -1
  126. package/lib/components/DonutChart/Arc/useArcStyles.styles.raw.js +0 -49
  127. package/lib/components/DonutChart/Arc/useArcStyles.styles.raw.js.map +0 -1
  128. package/lib/components/DonutChart/DonutChart.js +0 -349
  129. package/lib/components/DonutChart/DonutChart.js.map +0 -1
  130. package/lib/components/DonutChart/DonutChart.types.js +0 -4
  131. package/lib/components/DonutChart/DonutChart.types.js.map +0 -1
  132. package/lib/components/DonutChart/Pie/Pie.js +0 -72
  133. package/lib/components/DonutChart/Pie/Pie.js.map +0 -1
  134. package/lib/components/DonutChart/Pie/Pie.types.js +0 -1
  135. package/lib/components/DonutChart/Pie/Pie.types.js.map +0 -1
  136. package/lib/components/DonutChart/Pie/index.js +0 -2
  137. package/lib/components/DonutChart/Pie/index.js.map +0 -1
  138. package/lib/components/DonutChart/Pie/usePieStyles.styles.js +0 -41
  139. package/lib/components/DonutChart/Pie/usePieStyles.styles.js.map +0 -1
  140. package/lib/components/DonutChart/Pie/usePieStyles.styles.raw.js +0 -30
  141. package/lib/components/DonutChart/Pie/usePieStyles.styles.raw.js.map +0 -1
  142. package/lib/components/DonutChart/index.js +0 -3
  143. package/lib/components/DonutChart/index.js.map +0 -1
  144. package/lib/components/DonutChart/useDonutChartStyles.styles.js +0 -98
  145. package/lib/components/DonutChart/useDonutChartStyles.styles.js.map +0 -1
  146. package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js +0 -62
  147. package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js.map +0 -1
  148. package/lib/components/FunnelChart/FunnelChart.js +0 -401
  149. package/lib/components/FunnelChart/FunnelChart.js.map +0 -1
  150. package/lib/components/FunnelChart/FunnelChart.types.js +0 -4
  151. package/lib/components/FunnelChart/FunnelChart.types.js.map +0 -1
  152. package/lib/components/FunnelChart/funnelGeometry.js +0 -219
  153. package/lib/components/FunnelChart/funnelGeometry.js.map +0 -1
  154. package/lib/components/FunnelChart/index.js +0 -2
  155. package/lib/components/FunnelChart/index.js.map +0 -1
  156. package/lib/components/FunnelChart/useFunnelChartStyles.styles.js +0 -83
  157. package/lib/components/FunnelChart/useFunnelChartStyles.styles.js.map +0 -1
  158. package/lib/components/FunnelChart/useFunnelChartStyles.styles.raw.js +0 -65
  159. package/lib/components/FunnelChart/useFunnelChartStyles.styles.raw.js.map +0 -1
  160. package/lib/components/GanttChart/GanttChart.js +0 -535
  161. package/lib/components/GanttChart/GanttChart.js.map +0 -1
  162. package/lib/components/GanttChart/GanttChart.types.js +0 -4
  163. package/lib/components/GanttChart/GanttChart.types.js.map +0 -1
  164. package/lib/components/GanttChart/index.js +0 -2
  165. package/lib/components/GanttChart/index.js.map +0 -1
  166. package/lib/components/GanttChart/useGanttChartStyles.styles.js +0 -27
  167. package/lib/components/GanttChart/useGanttChartStyles.styles.js.map +0 -1
  168. package/lib/components/GanttChart/useGanttChartStyles.styles.raw.js +0 -26
  169. package/lib/components/GanttChart/useGanttChartStyles.styles.raw.js.map +0 -1
  170. package/lib/components/GaugeChart/GaugeChart.js +0 -568
  171. package/lib/components/GaugeChart/GaugeChart.js.map +0 -1
  172. package/lib/components/GaugeChart/GaugeChart.types.js +0 -4
  173. package/lib/components/GaugeChart/GaugeChart.types.js.map +0 -1
  174. package/lib/components/GaugeChart/index.js +0 -3
  175. package/lib/components/GaugeChart/index.js.map +0 -1
  176. package/lib/components/GaugeChart/useGaugeChartStyles.styles.js +0 -197
  177. package/lib/components/GaugeChart/useGaugeChartStyles.styles.js.map +0 -1
  178. package/lib/components/GaugeChart/useGaugeChartStyles.styles.raw.js +0 -149
  179. package/lib/components/GaugeChart/useGaugeChartStyles.styles.raw.js.map +0 -1
  180. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +0 -813
  181. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +0 -1
  182. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js +0 -4
  183. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js.map +0 -1
  184. package/lib/components/GroupedVerticalBarChart/index.js +0 -3
  185. package/lib/components/GroupedVerticalBarChart/index.js.map +0 -1
  186. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +0 -77
  187. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +0 -1
  188. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +0 -40
  189. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +0 -1
  190. package/lib/components/HeatMapChart/HeatMapChart.js +0 -677
  191. package/lib/components/HeatMapChart/HeatMapChart.js.map +0 -1
  192. package/lib/components/HeatMapChart/HeatMapChart.types.js +0 -4
  193. package/lib/components/HeatMapChart/HeatMapChart.types.js.map +0 -1
  194. package/lib/components/HeatMapChart/index.js +0 -3
  195. package/lib/components/HeatMapChart/index.js.map +0 -1
  196. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js +0 -48
  197. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +0 -1
  198. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +0 -42
  199. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +0 -1
  200. package/lib/components/HorizontalBarChart/HorizontalBarChart.js +0 -411
  201. package/lib/components/HorizontalBarChart/HorizontalBarChart.js.map +0 -1
  202. package/lib/components/HorizontalBarChart/HorizontalBarChart.types.js +0 -7
  203. package/lib/components/HorizontalBarChart/HorizontalBarChart.types.js.map +0 -1
  204. package/lib/components/HorizontalBarChart/index.js +0 -3
  205. package/lib/components/HorizontalBarChart/index.js.map +0 -1
  206. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +0 -175
  207. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +0 -1
  208. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js +0 -125
  209. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js.map +0 -1
  210. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +0 -720
  211. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +0 -1
  212. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js +0 -4
  213. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js.map +0 -1
  214. package/lib/components/HorizontalBarChartWithAxis/index.js +0 -3
  215. package/lib/components/HorizontalBarChartWithAxis/index.js.map +0 -1
  216. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +0 -62
  217. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +0 -1
  218. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +0 -54
  219. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +0 -1
  220. package/lib/components/Legends/Legends.js +0 -323
  221. package/lib/components/Legends/Legends.js.map +0 -1
  222. package/lib/components/Legends/Legends.types.js +0 -3
  223. package/lib/components/Legends/Legends.types.js.map +0 -1
  224. package/lib/components/Legends/OverflowMenu.js +0 -33
  225. package/lib/components/Legends/OverflowMenu.js.map +0 -1
  226. package/lib/components/Legends/index.js +0 -3
  227. package/lib/components/Legends/index.js.map +0 -1
  228. package/lib/components/Legends/shape.js +0 -36
  229. package/lib/components/Legends/shape.js.map +0 -1
  230. package/lib/components/Legends/useLegendsStyles.styles.js +0 -262
  231. package/lib/components/Legends/useLegendsStyles.styles.js.map +0 -1
  232. package/lib/components/Legends/useLegendsStyles.styles.raw.js +0 -142
  233. package/lib/components/Legends/useLegendsStyles.styles.raw.js.map +0 -1
  234. package/lib/components/LineChart/LineChart.js +0 -1332
  235. package/lib/components/LineChart/LineChart.js.map +0 -1
  236. package/lib/components/LineChart/LineChart.types.js +0 -3
  237. package/lib/components/LineChart/LineChart.types.js.map +0 -1
  238. package/lib/components/LineChart/eventAnnotation/EventAnnotation.js +0 -118
  239. package/lib/components/LineChart/eventAnnotation/EventAnnotation.js.map +0 -1
  240. package/lib/components/LineChart/eventAnnotation/LabelLink.js +0 -59
  241. package/lib/components/LineChart/eventAnnotation/LabelLink.js.map +0 -1
  242. package/lib/components/LineChart/eventAnnotation/Textbox.js +0 -42
  243. package/lib/components/LineChart/eventAnnotation/Textbox.js.map +0 -1
  244. package/lib/components/LineChart/index.js +0 -4
  245. package/lib/components/LineChart/index.js.map +0 -1
  246. package/lib/components/LineChart/useLineChartStyles.styles.js +0 -93
  247. package/lib/components/LineChart/useLineChartStyles.styles.js.map +0 -1
  248. package/lib/components/LineChart/useLineChartStyles.styles.raw.js +0 -50
  249. package/lib/components/LineChart/useLineChartStyles.styles.raw.js.map +0 -1
  250. package/lib/components/PolarChart/PolarChart.js +0 -577
  251. package/lib/components/PolarChart/PolarChart.js.map +0 -1
  252. package/lib/components/PolarChart/PolarChart.types.js +0 -4
  253. package/lib/components/PolarChart/PolarChart.types.js.map +0 -1
  254. package/lib/components/PolarChart/PolarChart.utils.js +0 -174
  255. package/lib/components/PolarChart/PolarChart.utils.js.map +0 -1
  256. package/lib/components/PolarChart/index.js +0 -2
  257. package/lib/components/PolarChart/index.js.map +0 -1
  258. package/lib/components/PolarChart/usePolarChartStyles.styles.js +0 -72
  259. package/lib/components/PolarChart/usePolarChartStyles.styles.js.map +0 -1
  260. package/lib/components/PolarChart/usePolarChartStyles.styles.raw.js +0 -61
  261. package/lib/components/PolarChart/usePolarChartStyles.styles.raw.js.map +0 -1
  262. package/lib/components/ResponsiveContainer/ResponsiveContainer.js +0 -99
  263. package/lib/components/ResponsiveContainer/ResponsiveContainer.js.map +0 -1
  264. package/lib/components/ResponsiveContainer/ResponsiveContainer.types.js +0 -4
  265. package/lib/components/ResponsiveContainer/ResponsiveContainer.types.js.map +0 -1
  266. package/lib/components/ResponsiveContainer/index.js +0 -3
  267. package/lib/components/ResponsiveContainer/index.js.map +0 -1
  268. package/lib/components/ResponsiveContainer/useResponsiveChildStyles.styles.js +0 -30
  269. package/lib/components/ResponsiveContainer/useResponsiveChildStyles.styles.js.map +0 -1
  270. package/lib/components/ResponsiveContainer/useResponsiveChildStyles.styles.raw.js +0 -29
  271. package/lib/components/ResponsiveContainer/useResponsiveChildStyles.styles.raw.js.map +0 -1
  272. package/lib/components/ResponsiveContainer/withResponsiveContainer.js +0 -20
  273. package/lib/components/ResponsiveContainer/withResponsiveContainer.js.map +0 -1
  274. package/lib/components/SankeyChart/SankeyChart.js +0 -1026
  275. package/lib/components/SankeyChart/SankeyChart.js.map +0 -1
  276. package/lib/components/SankeyChart/SankeyChart.types.js +0 -3
  277. package/lib/components/SankeyChart/SankeyChart.types.js.map +0 -1
  278. package/lib/components/SankeyChart/index.js +0 -3
  279. package/lib/components/SankeyChart/index.js.map +0 -1
  280. package/lib/components/SankeyChart/useSankeyChartStyles.styles.js +0 -123
  281. package/lib/components/SankeyChart/useSankeyChartStyles.styles.js.map +0 -1
  282. package/lib/components/SankeyChart/useSankeyChartStyles.styles.raw.js +0 -79
  283. package/lib/components/SankeyChart/useSankeyChartStyles.styles.raw.js.map +0 -1
  284. package/lib/components/ScatterChart/ScatterChart.js +0 -544
  285. package/lib/components/ScatterChart/ScatterChart.js.map +0 -1
  286. package/lib/components/ScatterChart/ScatterChart.types.js +0 -4
  287. package/lib/components/ScatterChart/ScatterChart.types.js.map +0 -1
  288. package/lib/components/ScatterChart/index.js +0 -3
  289. package/lib/components/ScatterChart/index.js.map +0 -1
  290. package/lib/components/ScatterChart/useScatterChartStyles.styles.js +0 -84
  291. package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +0 -1
  292. package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js +0 -41
  293. package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +0 -1
  294. package/lib/components/Sparkline/Sparkline.js +0 -123
  295. package/lib/components/Sparkline/Sparkline.js.map +0 -1
  296. package/lib/components/Sparkline/Sparkline.types.js +0 -4
  297. package/lib/components/Sparkline/Sparkline.types.js.map +0 -1
  298. package/lib/components/Sparkline/index.js +0 -3
  299. package/lib/components/Sparkline/index.js.map +0 -1
  300. package/lib/components/Sparkline/useSparklineStyles.styles.js +0 -40
  301. package/lib/components/Sparkline/useSparklineStyles.styles.js.map +0 -1
  302. package/lib/components/Sparkline/useSparklineStyles.styles.raw.js +0 -31
  303. package/lib/components/Sparkline/useSparklineStyles.styles.raw.js.map +0 -1
  304. package/lib/components/VegaDeclarativeChart/VegaDeclarativeChart.js +0 -405
  305. package/lib/components/VegaDeclarativeChart/VegaDeclarativeChart.js.map +0 -1
  306. package/lib/components/VegaDeclarativeChart/VegaDeclarativeChartHooks.js +0 -20
  307. package/lib/components/VegaDeclarativeChart/VegaDeclarativeChartHooks.js.map +0 -1
  308. package/lib/components/VegaDeclarativeChart/VegaLiteColorAdapter.js +0 -415
  309. package/lib/components/VegaDeclarativeChart/VegaLiteColorAdapter.js.map +0 -1
  310. package/lib/components/VegaDeclarativeChart/VegaLiteExpressionEvaluator.js +0 -537
  311. package/lib/components/VegaDeclarativeChart/VegaLiteExpressionEvaluator.js.map +0 -1
  312. package/lib/components/VegaDeclarativeChart/VegaLiteSchemaAdapter.js +0 -3279
  313. package/lib/components/VegaDeclarativeChart/VegaLiteSchemaAdapter.js.map +0 -1
  314. package/lib/components/VegaDeclarativeChart/VegaLiteTypes.js +0 -28
  315. package/lib/components/VegaDeclarativeChart/VegaLiteTypes.js.map +0 -1
  316. package/lib/components/VegaDeclarativeChart/index.js +0 -1
  317. package/lib/components/VegaDeclarativeChart/index.js.map +0 -1
  318. package/lib/components/VerticalBarChart/VerticalBarChart.js +0 -930
  319. package/lib/components/VerticalBarChart/VerticalBarChart.js.map +0 -1
  320. package/lib/components/VerticalBarChart/VerticalBarChart.types.js +0 -4
  321. package/lib/components/VerticalBarChart/VerticalBarChart.types.js.map +0 -1
  322. package/lib/components/VerticalBarChart/index.js +0 -3
  323. package/lib/components/VerticalBarChart/index.js.map +0 -1
  324. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +0 -86
  325. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +0 -1
  326. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +0 -48
  327. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +0 -1
  328. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +0 -1077
  329. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +0 -1
  330. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js +0 -4
  331. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +0 -1
  332. package/lib/components/VerticalStackedBarChart/index.js +0 -3
  333. package/lib/components/VerticalStackedBarChart/index.js.map +0 -1
  334. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +0 -74
  335. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +0 -1
  336. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +0 -38
  337. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +0 -1
  338. package/lib/index.js +0 -26
  339. package/lib/index.js.map +0 -1
  340. package/lib/types/ChartAnnotation.js +0 -1
  341. package/lib/types/ChartAnnotation.js.map +0 -1
  342. package/lib/types/DataPoint.js +0 -3
  343. package/lib/types/DataPoint.js.map +0 -1
  344. package/lib/types/EventAnnotation.js +0 -1
  345. package/lib/types/EventAnnotation.js.map +0 -1
  346. package/lib/types/LegendDataItem.js +0 -1
  347. package/lib/types/LegendDataItem.js.map +0 -1
  348. package/lib/types/index.js +0 -3
  349. package/lib/types/index.js.map +0 -1
  350. package/lib/utilities/ChartTitle.js +0 -45
  351. package/lib/utilities/ChartTitle.js.map +0 -1
  352. package/lib/utilities/Common.styles.js +0 -117
  353. package/lib/utilities/Common.styles.js.map +0 -1
  354. package/lib/utilities/Common.styles.raw.js +0 -115
  355. package/lib/utilities/Common.styles.raw.js.map +0 -1
  356. package/lib/utilities/FocusableTooltipText.js +0 -65
  357. package/lib/utilities/FocusableTooltipText.js.map +0 -1
  358. package/lib/utilities/KeyCodes.js +0 -11
  359. package/lib/utilities/KeyCodes.js.map +0 -1
  360. package/lib/utilities/SVGTooltipText.js +0 -179
  361. package/lib/utilities/SVGTooltipText.js.map +0 -1
  362. package/lib/utilities/async-utils.js +0 -380
  363. package/lib/utilities/async-utils.js.map +0 -1
  364. package/lib/utilities/colors.js +0 -281
  365. package/lib/utilities/colors.js.map +0 -1
  366. package/lib/utilities/getWindow.js +0 -25
  367. package/lib/utilities/getWindow.js.map +0 -1
  368. package/lib/utilities/hooks.js +0 -34
  369. package/lib/utilities/hooks.js.map +0 -1
  370. package/lib/utilities/image-export-utils.js +0 -405
  371. package/lib/utilities/image-export-utils.js.map +0 -1
  372. package/lib/utilities/index.js +0 -5
  373. package/lib/utilities/index.js.map +0 -1
  374. package/lib/utilities/overflow-utils.js +0 -27
  375. package/lib/utilities/overflow-utils.js.map +0 -1
  376. package/lib/utilities/scatterpolar-utils.js +0 -52
  377. package/lib/utilities/scatterpolar-utils.js.map +0 -1
  378. package/lib/utilities/string.js +0 -32
  379. package/lib/utilities/string.js.map +0 -1
  380. package/lib/utilities/test-data.js +0 -565
  381. package/lib/utilities/test-data.js.map +0 -1
  382. package/lib/utilities/utilities.js +0 -1990
  383. package/lib/utilities/utilities.js.map +0 -1
  384. package/lib/utilities/vbc-utils.js +0 -51
  385. package/lib/utilities/vbc-utils.js.map +0 -1
  386. package/lib-commonjs/AnnotationOnlyChart.js +0 -6
  387. package/lib-commonjs/AnnotationOnlyChart.js.map +0 -1
  388. package/lib-commonjs/AreaChart.js +0 -6
  389. package/lib-commonjs/AreaChart.js.map +0 -1
  390. package/lib-commonjs/CartesianChart.js +0 -6
  391. package/lib-commonjs/CartesianChart.js.map +0 -1
  392. package/lib-commonjs/ChartTable.js +0 -6
  393. package/lib-commonjs/ChartTable.js.map +0 -1
  394. package/lib-commonjs/DeclarativeChart.js +0 -6
  395. package/lib-commonjs/DeclarativeChart.js.map +0 -1
  396. package/lib-commonjs/DonutChart.js +0 -6
  397. package/lib-commonjs/DonutChart.js.map +0 -1
  398. package/lib-commonjs/FunnelChart.js +0 -6
  399. package/lib-commonjs/FunnelChart.js.map +0 -1
  400. package/lib-commonjs/GanttChart.js +0 -6
  401. package/lib-commonjs/GanttChart.js.map +0 -1
  402. package/lib-commonjs/GaugeChart.js +0 -6
  403. package/lib-commonjs/GaugeChart.js.map +0 -1
  404. package/lib-commonjs/GroupedVerticalBarChart.js +0 -6
  405. package/lib-commonjs/GroupedVerticalBarChart.js.map +0 -1
  406. package/lib-commonjs/HeatMapChart.js +0 -6
  407. package/lib-commonjs/HeatMapChart.js.map +0 -1
  408. package/lib-commonjs/HorizontalBarChart.js +0 -6
  409. package/lib-commonjs/HorizontalBarChart.js.map +0 -1
  410. package/lib-commonjs/HorizontalBarChartWithAxis.js +0 -6
  411. package/lib-commonjs/HorizontalBarChartWithAxis.js.map +0 -1
  412. package/lib-commonjs/Legends.js +0 -6
  413. package/lib-commonjs/Legends.js.map +0 -1
  414. package/lib-commonjs/LineChart.js +0 -6
  415. package/lib-commonjs/LineChart.js.map +0 -1
  416. package/lib-commonjs/PolarChart.js +0 -6
  417. package/lib-commonjs/PolarChart.js.map +0 -1
  418. package/lib-commonjs/Popover.js +0 -6
  419. package/lib-commonjs/Popover.js.map +0 -1
  420. package/lib-commonjs/ResponsiveContainer.js +0 -6
  421. package/lib-commonjs/ResponsiveContainer.js.map +0 -1
  422. package/lib-commonjs/SankeyChart.js +0 -6
  423. package/lib-commonjs/SankeyChart.js.map +0 -1
  424. package/lib-commonjs/ScatterChart.js +0 -6
  425. package/lib-commonjs/ScatterChart.js.map +0 -1
  426. package/lib-commonjs/Sparkline.js +0 -6
  427. package/lib-commonjs/Sparkline.js.map +0 -1
  428. package/lib-commonjs/VegaDeclarativeChart.js +0 -6
  429. package/lib-commonjs/VegaDeclarativeChart.js.map +0 -1
  430. package/lib-commonjs/VerticalBarChart.js +0 -6
  431. package/lib-commonjs/VerticalBarChart.js.map +0 -1
  432. package/lib-commonjs/VerticalStackedBarChart.js +0 -6
  433. package/lib-commonjs/VerticalStackedBarChart.js.map +0 -1
  434. package/lib-commonjs/components/AnnotationOnlyChart/AnnotationOnlyChart.js +0 -207
  435. package/lib-commonjs/components/AnnotationOnlyChart/AnnotationOnlyChart.js.map +0 -1
  436. package/lib-commonjs/components/AnnotationOnlyChart/AnnotationOnlyChart.types.js +0 -6
  437. package/lib-commonjs/components/AnnotationOnlyChart/AnnotationOnlyChart.types.js.map +0 -1
  438. package/lib-commonjs/components/AnnotationOnlyChart/index.js +0 -7
  439. package/lib-commonjs/components/AnnotationOnlyChart/index.js.map +0 -1
  440. package/lib-commonjs/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.js +0 -57
  441. package/lib-commonjs/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.js.map +0 -1
  442. package/lib-commonjs/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.raw.js +0 -34
  443. package/lib-commonjs/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.raw.js.map +0 -1
  444. package/lib-commonjs/components/AreaChart/AreaChart.js +0 -938
  445. package/lib-commonjs/components/AreaChart/AreaChart.js.map +0 -1
  446. package/lib-commonjs/components/AreaChart/AreaChart.types.js +0 -7
  447. package/lib-commonjs/components/AreaChart/AreaChart.types.js.map +0 -1
  448. package/lib-commonjs/components/AreaChart/index.js +0 -8
  449. package/lib-commonjs/components/AreaChart/index.js.map +0 -1
  450. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js +0 -96
  451. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +0 -1
  452. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js +0 -49
  453. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js.map +0 -1
  454. package/lib-commonjs/components/ChartTable/ChartTable.js +0 -171
  455. package/lib-commonjs/components/ChartTable/ChartTable.js.map +0 -1
  456. package/lib-commonjs/components/ChartTable/ChartTable.types.js +0 -7
  457. package/lib-commonjs/components/ChartTable/ChartTable.types.js.map +0 -1
  458. package/lib-commonjs/components/ChartTable/index.js +0 -8
  459. package/lib-commonjs/components/ChartTable/index.js.map +0 -1
  460. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js +0 -200
  461. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js.map +0 -1
  462. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js +0 -82
  463. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js.map +0 -1
  464. package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.js +0 -670
  465. package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.js.map +0 -1
  466. package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js +0 -4
  467. package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js.map +0 -1
  468. package/lib-commonjs/components/CommonComponents/Annotations/index.js +0 -7
  469. package/lib-commonjs/components/CommonComponents/Annotations/index.js.map +0 -1
  470. package/lib-commonjs/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.js +0 -325
  471. package/lib-commonjs/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.js.map +0 -1
  472. package/lib-commonjs/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.raw.js +0 -174
  473. package/lib-commonjs/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.raw.js.map +0 -1
  474. package/lib-commonjs/components/CommonComponents/CartesianChart.js +0 -673
  475. package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +0 -1
  476. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js +0 -5
  477. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +0 -1
  478. package/lib-commonjs/components/CommonComponents/ChartPopover.js +0 -207
  479. package/lib-commonjs/components/CommonComponents/ChartPopover.js.map +0 -1
  480. package/lib-commonjs/components/CommonComponents/ChartPopover.types.js +0 -4
  481. package/lib-commonjs/components/CommonComponents/ChartPopover.types.js.map +0 -1
  482. package/lib-commonjs/components/CommonComponents/index.js +0 -11
  483. package/lib-commonjs/components/CommonComponents/index.js.map +0 -1
  484. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +0 -268
  485. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +0 -1
  486. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +0 -144
  487. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +0 -1
  488. package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js +0 -238
  489. package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js.map +0 -1
  490. package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.raw.js +0 -141
  491. package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.raw.js.map +0 -1
  492. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +0 -400
  493. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +0 -1
  494. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +0 -195
  495. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +0 -1
  496. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +0 -3577
  497. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +0 -1
  498. package/lib-commonjs/components/DeclarativeChart/index.js +0 -6
  499. package/lib-commonjs/components/DeclarativeChart/index.js.map +0 -1
  500. package/lib-commonjs/components/DonutChart/Arc/Arc.js +0 -125
  501. package/lib-commonjs/components/DonutChart/Arc/Arc.js.map +0 -1
  502. package/lib-commonjs/components/DonutChart/Arc/Arc.types.js +0 -4
  503. package/lib-commonjs/components/DonutChart/Arc/Arc.types.js.map +0 -1
  504. package/lib-commonjs/components/DonutChart/Arc/index.js +0 -7
  505. package/lib-commonjs/components/DonutChart/Arc/index.js.map +0 -1
  506. package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.js +0 -110
  507. package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.js.map +0 -1
  508. package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.raw.js +0 -63
  509. package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.raw.js.map +0 -1
  510. package/lib-commonjs/components/DonutChart/DonutChart.js +0 -356
  511. package/lib-commonjs/components/DonutChart/DonutChart.js.map +0 -1
  512. package/lib-commonjs/components/DonutChart/DonutChart.types.js +0 -7
  513. package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +0 -1
  514. package/lib-commonjs/components/DonutChart/Pie/Pie.js +0 -79
  515. package/lib-commonjs/components/DonutChart/Pie/Pie.js.map +0 -1
  516. package/lib-commonjs/components/DonutChart/Pie/Pie.types.js +0 -4
  517. package/lib-commonjs/components/DonutChart/Pie/Pie.types.js.map +0 -1
  518. package/lib-commonjs/components/DonutChart/Pie/index.js +0 -7
  519. package/lib-commonjs/components/DonutChart/Pie/index.js.map +0 -1
  520. package/lib-commonjs/components/DonutChart/Pie/usePieStyles.styles.js +0 -55
  521. package/lib-commonjs/components/DonutChart/Pie/usePieStyles.styles.js.map +0 -1
  522. package/lib-commonjs/components/DonutChart/Pie/usePieStyles.styles.raw.js +0 -44
  523. package/lib-commonjs/components/DonutChart/Pie/usePieStyles.styles.raw.js.map +0 -1
  524. package/lib-commonjs/components/DonutChart/index.js +0 -8
  525. package/lib-commonjs/components/DonutChart/index.js.map +0 -1
  526. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js +0 -145
  527. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js.map +0 -1
  528. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js +0 -76
  529. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js.map +0 -1
  530. package/lib-commonjs/components/FunnelChart/FunnelChart.js +0 -412
  531. package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +0 -1
  532. package/lib-commonjs/components/FunnelChart/FunnelChart.types.js +0 -7
  533. package/lib-commonjs/components/FunnelChart/FunnelChart.types.js.map +0 -1
  534. package/lib-commonjs/components/FunnelChart/funnelGeometry.js +0 -246
  535. package/lib-commonjs/components/FunnelChart/funnelGeometry.js.map +0 -1
  536. package/lib-commonjs/components/FunnelChart/index.js +0 -7
  537. package/lib-commonjs/components/FunnelChart/index.js.map +0 -1
  538. package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.js +0 -118
  539. package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.js.map +0 -1
  540. package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.raw.js +0 -79
  541. package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.raw.js.map +0 -1
  542. package/lib-commonjs/components/GanttChart/GanttChart.js +0 -546
  543. package/lib-commonjs/components/GanttChart/GanttChart.js.map +0 -1
  544. package/lib-commonjs/components/GanttChart/GanttChart.types.js +0 -7
  545. package/lib-commonjs/components/GanttChart/GanttChart.types.js.map +0 -1
  546. package/lib-commonjs/components/GanttChart/index.js +0 -7
  547. package/lib-commonjs/components/GanttChart/index.js.map +0 -1
  548. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js +0 -42
  549. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js.map +0 -1
  550. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.raw.js +0 -42
  551. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.raw.js.map +0 -1
  552. package/lib-commonjs/components/GaugeChart/GaugeChart.js +0 -597
  553. package/lib-commonjs/components/GaugeChart/GaugeChart.js.map +0 -1
  554. package/lib-commonjs/components/GaugeChart/GaugeChart.types.js +0 -7
  555. package/lib-commonjs/components/GaugeChart/GaugeChart.types.js.map +0 -1
  556. package/lib-commonjs/components/GaugeChart/index.js +0 -8
  557. package/lib-commonjs/components/GaugeChart/index.js.map +0 -1
  558. package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.js +0 -281
  559. package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.js.map +0 -1
  560. package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.raw.js +0 -167
  561. package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.raw.js.map +0 -1
  562. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +0 -818
  563. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +0 -1
  564. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js +0 -7
  565. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js.map +0 -1
  566. package/lib-commonjs/components/GroupedVerticalBarChart/index.js +0 -8
  567. package/lib-commonjs/components/GroupedVerticalBarChart/index.js.map +0 -1
  568. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +0 -116
  569. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +0 -1
  570. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +0 -56
  571. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +0 -1
  572. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +0 -688
  573. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +0 -1
  574. package/lib-commonjs/components/HeatMapChart/HeatMapChart.types.js +0 -7
  575. package/lib-commonjs/components/HeatMapChart/HeatMapChart.types.js.map +0 -1
  576. package/lib-commonjs/components/HeatMapChart/index.js +0 -8
  577. package/lib-commonjs/components/HeatMapChart/index.js.map +0 -1
  578. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js +0 -71
  579. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +0 -1
  580. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +0 -60
  581. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +0 -1
  582. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js +0 -417
  583. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js.map +0 -1
  584. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.types.js +0 -17
  585. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.types.js.map +0 -1
  586. package/lib-commonjs/components/HorizontalBarChart/index.js +0 -8
  587. package/lib-commonjs/components/HorizontalBarChart/index.js.map +0 -1
  588. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +0 -264
  589. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +0 -1
  590. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js +0 -139
  591. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js.map +0 -1
  592. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +0 -726
  593. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +0 -1
  594. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js +0 -7
  595. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js.map +0 -1
  596. package/lib-commonjs/components/HorizontalBarChartWithAxis/index.js +0 -8
  597. package/lib-commonjs/components/HorizontalBarChartWithAxis/index.js.map +0 -1
  598. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +0 -86
  599. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +0 -1
  600. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +0 -70
  601. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +0 -1
  602. package/lib-commonjs/components/Legends/Legends.js +0 -333
  603. package/lib-commonjs/components/Legends/Legends.js.map +0 -1
  604. package/lib-commonjs/components/Legends/Legends.types.js +0 -6
  605. package/lib-commonjs/components/Legends/Legends.types.js.map +0 -1
  606. package/lib-commonjs/components/Legends/OverflowMenu.js +0 -44
  607. package/lib-commonjs/components/Legends/OverflowMenu.js.map +0 -1
  608. package/lib-commonjs/components/Legends/index.js +0 -8
  609. package/lib-commonjs/components/Legends/index.js.map +0 -1
  610. package/lib-commonjs/components/Legends/shape.js +0 -47
  611. package/lib-commonjs/components/Legends/shape.js.map +0 -1
  612. package/lib-commonjs/components/Legends/useLegendsStyles.styles.js +0 -456
  613. package/lib-commonjs/components/Legends/useLegendsStyles.styles.js.map +0 -1
  614. package/lib-commonjs/components/Legends/useLegendsStyles.styles.raw.js +0 -178
  615. package/lib-commonjs/components/Legends/useLegendsStyles.styles.raw.js.map +0 -1
  616. package/lib-commonjs/components/LineChart/LineChart.js +0 -1337
  617. package/lib-commonjs/components/LineChart/LineChart.js.map +0 -1
  618. package/lib-commonjs/components/LineChart/LineChart.types.js +0 -6
  619. package/lib-commonjs/components/LineChart/LineChart.types.js.map +0 -1
  620. package/lib-commonjs/components/LineChart/eventAnnotation/EventAnnotation.js +0 -129
  621. package/lib-commonjs/components/LineChart/eventAnnotation/EventAnnotation.js.map +0 -1
  622. package/lib-commonjs/components/LineChart/eventAnnotation/LabelLink.js +0 -70
  623. package/lib-commonjs/components/LineChart/eventAnnotation/LabelLink.js.map +0 -1
  624. package/lib-commonjs/components/LineChart/eventAnnotation/Textbox.js +0 -53
  625. package/lib-commonjs/components/LineChart/eventAnnotation/Textbox.js.map +0 -1
  626. package/lib-commonjs/components/LineChart/index.js +0 -9
  627. package/lib-commonjs/components/LineChart/index.js.map +0 -1
  628. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js +0 -132
  629. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +0 -1
  630. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js +0 -63
  631. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js.map +0 -1
  632. package/lib-commonjs/components/PolarChart/PolarChart.js +0 -587
  633. package/lib-commonjs/components/PolarChart/PolarChart.js.map +0 -1
  634. package/lib-commonjs/components/PolarChart/PolarChart.types.js +0 -7
  635. package/lib-commonjs/components/PolarChart/PolarChart.types.js.map +0 -1
  636. package/lib-commonjs/components/PolarChart/PolarChart.utils.js +0 -204
  637. package/lib-commonjs/components/PolarChart/PolarChart.utils.js.map +0 -1
  638. package/lib-commonjs/components/PolarChart/index.js +0 -7
  639. package/lib-commonjs/components/PolarChart/index.js.map +0 -1
  640. package/lib-commonjs/components/PolarChart/usePolarChartStyles.styles.js +0 -107
  641. package/lib-commonjs/components/PolarChart/usePolarChartStyles.styles.js.map +0 -1
  642. package/lib-commonjs/components/PolarChart/usePolarChartStyles.styles.raw.js +0 -75
  643. package/lib-commonjs/components/PolarChart/usePolarChartStyles.styles.raw.js.map +0 -1
  644. package/lib-commonjs/components/ResponsiveContainer/ResponsiveContainer.js +0 -107
  645. package/lib-commonjs/components/ResponsiveContainer/ResponsiveContainer.js.map +0 -1
  646. package/lib-commonjs/components/ResponsiveContainer/ResponsiveContainer.types.js +0 -7
  647. package/lib-commonjs/components/ResponsiveContainer/ResponsiveContainer.types.js.map +0 -1
  648. package/lib-commonjs/components/ResponsiveContainer/index.js +0 -8
  649. package/lib-commonjs/components/ResponsiveContainer/index.js.map +0 -1
  650. package/lib-commonjs/components/ResponsiveContainer/useResponsiveChildStyles.styles.js +0 -50
  651. package/lib-commonjs/components/ResponsiveContainer/useResponsiveChildStyles.styles.js.map +0 -1
  652. package/lib-commonjs/components/ResponsiveContainer/useResponsiveChildStyles.styles.raw.js +0 -47
  653. package/lib-commonjs/components/ResponsiveContainer/useResponsiveChildStyles.styles.raw.js.map +0 -1
  654. package/lib-commonjs/components/ResponsiveContainer/withResponsiveContainer.js +0 -28
  655. package/lib-commonjs/components/ResponsiveContainer/withResponsiveContainer.js.map +0 -1
  656. package/lib-commonjs/components/SankeyChart/SankeyChart.js +0 -1042
  657. package/lib-commonjs/components/SankeyChart/SankeyChart.js.map +0 -1
  658. package/lib-commonjs/components/SankeyChart/SankeyChart.types.js +0 -6
  659. package/lib-commonjs/components/SankeyChart/SankeyChart.types.js.map +0 -1
  660. package/lib-commonjs/components/SankeyChart/index.js +0 -8
  661. package/lib-commonjs/components/SankeyChart/index.js.map +0 -1
  662. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js +0 -202
  663. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js.map +0 -1
  664. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.raw.js +0 -97
  665. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.raw.js.map +0 -1
  666. package/lib-commonjs/components/ScatterChart/ScatterChart.js +0 -550
  667. package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +0 -1
  668. package/lib-commonjs/components/ScatterChart/ScatterChart.types.js +0 -7
  669. package/lib-commonjs/components/ScatterChart/ScatterChart.types.js.map +0 -1
  670. package/lib-commonjs/components/ScatterChart/index.js +0 -8
  671. package/lib-commonjs/components/ScatterChart/index.js.map +0 -1
  672. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js +0 -120
  673. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +0 -1
  674. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js +0 -55
  675. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +0 -1
  676. package/lib-commonjs/components/Sparkline/Sparkline.js +0 -129
  677. package/lib-commonjs/components/Sparkline/Sparkline.js.map +0 -1
  678. package/lib-commonjs/components/Sparkline/Sparkline.types.js +0 -7
  679. package/lib-commonjs/components/Sparkline/Sparkline.types.js.map +0 -1
  680. package/lib-commonjs/components/Sparkline/index.js +0 -8
  681. package/lib-commonjs/components/Sparkline/index.js.map +0 -1
  682. package/lib-commonjs/components/Sparkline/useSparklineStyles.styles.js +0 -57
  683. package/lib-commonjs/components/Sparkline/useSparklineStyles.styles.js.map +0 -1
  684. package/lib-commonjs/components/Sparkline/useSparklineStyles.styles.raw.js +0 -45
  685. package/lib-commonjs/components/Sparkline/useSparklineStyles.styles.raw.js.map +0 -1
  686. package/lib-commonjs/components/VegaDeclarativeChart/VegaDeclarativeChart.js +0 -274
  687. package/lib-commonjs/components/VegaDeclarativeChart/VegaDeclarativeChart.js.map +0 -1
  688. package/lib-commonjs/components/VegaDeclarativeChart/VegaDeclarativeChartHooks.js +0 -35
  689. package/lib-commonjs/components/VegaDeclarativeChart/VegaDeclarativeChartHooks.js.map +0 -1
  690. package/lib-commonjs/components/VegaDeclarativeChart/VegaLiteColorAdapter.js +0 -412
  691. package/lib-commonjs/components/VegaDeclarativeChart/VegaLiteColorAdapter.js.map +0 -1
  692. package/lib-commonjs/components/VegaDeclarativeChart/VegaLiteExpressionEvaluator.js +0 -533
  693. package/lib-commonjs/components/VegaDeclarativeChart/VegaLiteExpressionEvaluator.js.map +0 -1
  694. package/lib-commonjs/components/VegaDeclarativeChart/VegaLiteSchemaAdapter.js +0 -3214
  695. package/lib-commonjs/components/VegaDeclarativeChart/VegaLiteSchemaAdapter.js.map +0 -1
  696. package/lib-commonjs/components/VegaDeclarativeChart/VegaLiteTypes.js +0 -31
  697. package/lib-commonjs/components/VegaDeclarativeChart/VegaLiteTypes.js.map +0 -1
  698. package/lib-commonjs/components/VegaDeclarativeChart/index.js +0 -6
  699. package/lib-commonjs/components/VegaDeclarativeChart/index.js.map +0 -1
  700. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +0 -932
  701. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +0 -1
  702. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.types.js +0 -7
  703. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.types.js.map +0 -1
  704. package/lib-commonjs/components/VerticalBarChart/index.js +0 -8
  705. package/lib-commonjs/components/VerticalBarChart/index.js.map +0 -1
  706. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +0 -128
  707. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +0 -1
  708. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +0 -64
  709. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +0 -1
  710. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +0 -1088
  711. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +0 -1
  712. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js +0 -7
  713. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +0 -1
  714. package/lib-commonjs/components/VerticalStackedBarChart/index.js +0 -8
  715. package/lib-commonjs/components/VerticalStackedBarChart/index.js.map +0 -1
  716. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +0 -116
  717. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +0 -1
  718. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +0 -56
  719. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +0 -1
  720. package/lib-commonjs/index.js +0 -31
  721. package/lib-commonjs/index.js.map +0 -1
  722. package/lib-commonjs/types/ChartAnnotation.js +0 -4
  723. package/lib-commonjs/types/ChartAnnotation.js.map +0 -1
  724. package/lib-commonjs/types/DataPoint.js +0 -6
  725. package/lib-commonjs/types/DataPoint.js.map +0 -1
  726. package/lib-commonjs/types/EventAnnotation.js +0 -4
  727. package/lib-commonjs/types/EventAnnotation.js.map +0 -1
  728. package/lib-commonjs/types/LegendDataItem.js +0 -4
  729. package/lib-commonjs/types/LegendDataItem.js.map +0 -1
  730. package/lib-commonjs/types/index.js +0 -8
  731. package/lib-commonjs/types/index.js.map +0 -1
  732. package/lib-commonjs/utilities/ChartTitle.js +0 -53
  733. package/lib-commonjs/utilities/ChartTitle.js.map +0 -1
  734. package/lib-commonjs/utilities/Common.styles.js +0 -138
  735. package/lib-commonjs/utilities/Common.styles.js.map +0 -1
  736. package/lib-commonjs/utilities/Common.styles.raw.js +0 -138
  737. package/lib-commonjs/utilities/Common.styles.raw.js.map +0 -1
  738. package/lib-commonjs/utilities/FocusableTooltipText.js +0 -75
  739. package/lib-commonjs/utilities/FocusableTooltipText.js.map +0 -1
  740. package/lib-commonjs/utilities/KeyCodes.js +0 -21
  741. package/lib-commonjs/utilities/KeyCodes.js.map +0 -1
  742. package/lib-commonjs/utilities/SVGTooltipText.js +0 -189
  743. package/lib-commonjs/utilities/SVGTooltipText.js.map +0 -1
  744. package/lib-commonjs/utilities/async-utils.js +0 -382
  745. package/lib-commonjs/utilities/async-utils.js.map +0 -1
  746. package/lib-commonjs/utilities/colors.js +0 -311
  747. package/lib-commonjs/utilities/colors.js.map +0 -1
  748. package/lib-commonjs/utilities/getWindow.js +0 -28
  749. package/lib-commonjs/utilities/getWindow.js.map +0 -1
  750. package/lib-commonjs/utilities/hooks.js +0 -45
  751. package/lib-commonjs/utilities/hooks.js.map +0 -1
  752. package/lib-commonjs/utilities/image-export-utils.js +0 -423
  753. package/lib-commonjs/utilities/image-export-utils.js.map +0 -1
  754. package/lib-commonjs/utilities/index.js +0 -10
  755. package/lib-commonjs/utilities/index.js.map +0 -1
  756. package/lib-commonjs/utilities/overflow-utils.js +0 -36
  757. package/lib-commonjs/utilities/overflow-utils.js.map +0 -1
  758. package/lib-commonjs/utilities/scatterpolar-utils.js +0 -67
  759. package/lib-commonjs/utilities/scatterpolar-utils.js.map +0 -1
  760. package/lib-commonjs/utilities/string.js +0 -29
  761. package/lib-commonjs/utilities/string.js.map +0 -1
  762. package/lib-commonjs/utilities/test-data.js +0 -628
  763. package/lib-commonjs/utilities/test-data.js.map +0 -1
  764. package/lib-commonjs/utilities/utilities.js +0 -2016
  765. package/lib-commonjs/utilities/utilities.js.map +0 -1
  766. package/lib-commonjs/utilities/vbc-utils.js +0 -72
  767. package/lib-commonjs/utilities/vbc-utils.js.map +0 -1
@@ -1,3490 +0,0 @@
1
- 'use client';
2
- import { bin as d3Bin, extent as d3Extent, sum as d3Sum, min as d3Min, max as d3Max, range as d3Range } from 'd3-array';
3
- import { scaleLinear as d3ScaleLinear } from 'd3-scale';
4
- import { format as d3Format } from 'd3-format';
5
- import { DataVizPalette, getColorFromToken } from '../../utilities/colors';
6
- import { DEFAULT_DATE_STRING, findNumericMinMaxOfY, formatScientificLimitWidth, MIN_DONUT_RADIUS, calculatePrecision, precisionRound } from '../../utilities/utilities';
7
- import { isArrayOrTypedArray, isDate, isDateArray, isNumberArray, isStringArray, isYearArray, isInvalidValue, formatToLocaleString, isNumber, isObjectArray, getAxisIds, getAxisKey, isScatterAreaChart } from '@fluentui/chart-utilities';
8
- import { curveCardinal as d3CurveCardinal } from 'd3-shape';
9
- import { getOpacity, extractColor, resolveColor, createColorScale } from './PlotlyColorAdapter';
10
- import { rgb } from 'd3-color';
11
- export const NON_PLOT_KEY_PREFIX = 'nonplot_';
12
- export const SINGLE_REPEAT = 'repeat(1, 1fr)';
13
- const dashOptions = {
14
- dot: {
15
- strokeDasharray: '1, 5',
16
- strokeLinecap: 'round',
17
- strokeWidth: '2',
18
- lineBorderWidth: '4'
19
- },
20
- dash: {
21
- strokeDasharray: '5, 5',
22
- strokeLinecap: 'butt',
23
- strokeWidth: '2',
24
- lineBorderWidth: '4'
25
- },
26
- longdash: {
27
- strokeDasharray: '10, 5',
28
- strokeLinecap: 'butt',
29
- strokeWidth: '2',
30
- lineBorderWidth: '4'
31
- },
32
- dashdot: {
33
- strokeDasharray: '5, 5, 1, 5',
34
- strokeLinecap: 'butt',
35
- strokeWidth: '2',
36
- lineBorderWidth: '4'
37
- },
38
- longdashdot: {
39
- strokeDasharray: '10, 5, 1, 5',
40
- strokeLinecap: 'butt',
41
- strokeWidth: '2',
42
- lineBorderWidth: '4'
43
- },
44
- solid: {
45
- strokeDasharray: '0',
46
- strokeLinecap: 'butt',
47
- strokeWidth: '2',
48
- lineBorderWidth: '4'
49
- }
50
- };
51
- function getTitles(layout) {
52
- var _layout_xaxis, _layout_xaxis1, _layout_xaxis_title, _layout_xaxis2, _layout_yaxis, _layout_yaxis1, _layout_yaxis_title, _layout_yaxis2;
53
- const titleObj = layout === null || layout === void 0 ? void 0 : layout.title;
54
- var _titleObj_text;
55
- const chartTitle = typeof titleObj === 'string' ? titleObj : (_titleObj_text = titleObj === null || titleObj === void 0 ? void 0 : titleObj.text) !== null && _titleObj_text !== void 0 ? _titleObj_text : '';
56
- const titleFont = typeof titleObj === 'object' ? titleObj === null || titleObj === void 0 ? void 0 : titleObj.font : undefined;
57
- const titleXAnchor = typeof titleObj === 'object' ? titleObj === null || titleObj === void 0 ? void 0 : titleObj.xanchor : undefined;
58
- const titleYAnchor = typeof titleObj === 'object' ? titleObj === null || titleObj === void 0 ? void 0 : titleObj.yanchor : undefined;
59
- const titlePad = typeof titleObj === 'object' ? titleObj === null || titleObj === void 0 ? void 0 : titleObj.pad : undefined;
60
- const titleStyles = {
61
- ...titleFont ? {
62
- titleFont
63
- } : {},
64
- ...titleXAnchor ? {
65
- titleXAnchor
66
- } : {},
67
- ...titleYAnchor ? {
68
- titleYAnchor
69
- } : {},
70
- ...titlePad ? {
71
- titlePad
72
- } : {}
73
- };
74
- var _layout_xaxis_title_text, _layout_yaxis_title_text;
75
- const titles = {
76
- chartTitle,
77
- ...Object.keys(titleStyles).length > 0 ? {
78
- titleStyles
79
- } : {},
80
- xAxisTitle: typeof (layout === null || layout === void 0 ? void 0 : (_layout_xaxis = layout.xaxis) === null || _layout_xaxis === void 0 ? void 0 : _layout_xaxis.title) === 'string' ? layout === null || layout === void 0 ? void 0 : (_layout_xaxis1 = layout.xaxis) === null || _layout_xaxis1 === void 0 ? void 0 : _layout_xaxis1.title : (_layout_xaxis_title_text = layout === null || layout === void 0 ? void 0 : (_layout_xaxis2 = layout.xaxis) === null || _layout_xaxis2 === void 0 ? void 0 : (_layout_xaxis_title = _layout_xaxis2.title) === null || _layout_xaxis_title === void 0 ? void 0 : _layout_xaxis_title.text) !== null && _layout_xaxis_title_text !== void 0 ? _layout_xaxis_title_text : '',
81
- yAxisTitle: typeof (layout === null || layout === void 0 ? void 0 : (_layout_yaxis = layout.yaxis) === null || _layout_yaxis === void 0 ? void 0 : _layout_yaxis.title) === 'string' ? layout === null || layout === void 0 ? void 0 : (_layout_yaxis1 = layout.yaxis) === null || _layout_yaxis1 === void 0 ? void 0 : _layout_yaxis1.title : (_layout_yaxis_title_text = layout === null || layout === void 0 ? void 0 : (_layout_yaxis2 = layout.yaxis) === null || _layout_yaxis2 === void 0 ? void 0 : (_layout_yaxis_title = _layout_yaxis2.title) === null || _layout_yaxis_title === void 0 ? void 0 : _layout_yaxis_title.text) !== null && _layout_yaxis_title_text !== void 0 ? _layout_yaxis_title_text : '',
82
- xAxisAnnotation: chartTitle
83
- };
84
- return titles;
85
- }
86
- const getXAxisTickFormat = (series, layout)=>{
87
- const xAxis = getXAxisProperties(series, layout);
88
- if (xAxis === null || xAxis === void 0 ? void 0 : xAxis.tickformat) {
89
- return {
90
- tickFormat: xAxis === null || xAxis === void 0 ? void 0 : xAxis.tickformat
91
- };
92
- }
93
- return {};
94
- };
95
- const getYAxisTickFormat = (series, layout)=>{
96
- const yAxis = getYAxisProperties(series, layout);
97
- if (yAxis === null || yAxis === void 0 ? void 0 : yAxis.tickformat) {
98
- return {
99
- yAxisTickFormat: d3Format(yAxis === null || yAxis === void 0 ? void 0 : yAxis.tickformat)
100
- };
101
- }
102
- return {};
103
- };
104
- const getYMinMaxValues = (series, layout)=>{
105
- var _getYAxisProperties;
106
- const range = (_getYAxisProperties = getYAxisProperties(series, layout)) === null || _getYAxisProperties === void 0 ? void 0 : _getYAxisProperties.range;
107
- if (range && range.length === 2) {
108
- return {
109
- yMinValue: range[0],
110
- yMaxValue: range[1]
111
- };
112
- }
113
- return {};
114
- };
115
- const getXMinMaxValues = (series, layout)=>{
116
- var _getXAxisProperties;
117
- const range = (_getXAxisProperties = getXAxisProperties(series, layout)) === null || _getXAxisProperties === void 0 ? void 0 : _getXAxisProperties.range;
118
- if (range && range.length === 2) {
119
- return {
120
- xMinValue: range[0],
121
- xMaxValue: range[1],
122
- showRoundOffXTickValues: false
123
- };
124
- }
125
- return {};
126
- };
127
- const getYAxisProperties = (series, layout)=>{
128
- return layout === null || layout === void 0 ? void 0 : layout.yaxis;
129
- };
130
- const getXAxisProperties = (series, layout)=>{
131
- return layout === null || layout === void 0 ? void 0 : layout.xaxis;
132
- };
133
- const getFormattedCalloutYData = (yVal, yAxisFormat)=>{
134
- if (typeof (yAxisFormat === null || yAxisFormat === void 0 ? void 0 : yAxisFormat.yAxisTickFormat) === 'function' && typeof yVal === 'number') {
135
- return yAxisFormat.yAxisTickFormat(yVal);
136
- }
137
- return formatToLocaleString(yVal);
138
- };
139
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
140
- export const correctYearMonth = (xValues)=>{
141
- const presentYear = new Date().getFullYear();
142
- if (xValues.length > 0 && Array.isArray(xValues[0])) {
143
- throw new Error('updateXValues:: 2D array not supported');
144
- }
145
- const dates = xValues.map((possiblyMonthValue)=>{
146
- const parsedDate = `${possiblyMonthValue} 01, ${presentYear}`;
147
- return isDate(parsedDate) ? new Date(parsedDate) : null;
148
- });
149
- const filteredDateIndexPairs = dates.map((date, index)=>[
150
- date,
151
- index
152
- ]).filter(([date])=>date !== null);
153
- for(let i = filteredDateIndexPairs.length - 1; i > 0; i--){
154
- const currentDate = filteredDateIndexPairs[i][0];
155
- const previousDate = filteredDateIndexPairs[i - 1][0];
156
- const currentMonth = currentDate.getMonth();
157
- const previousMonth = previousDate.getMonth();
158
- const currentYear = currentDate.getFullYear();
159
- const previousYear = previousDate.getFullYear();
160
- if (previousMonth >= currentMonth) {
161
- filteredDateIndexPairs[i - 1][0].setFullYear(currentYear - 1);
162
- } else if (previousYear > currentYear) {
163
- filteredDateIndexPairs[i - 1][0].setFullYear(currentYear);
164
- }
165
- dates[filteredDateIndexPairs[i - 1][1]] = filteredDateIndexPairs[i - 1][0];
166
- }
167
- xValues = xValues.map((month, index)=>{
168
- if (dates[index] === null) {
169
- return null;
170
- }
171
- return `${month} 01, ${dates[index].getFullYear()}`;
172
- });
173
- return xValues;
174
- };
175
- const usesSecondaryYScale = (series, layout)=>{
176
- var _layout_yaxis2, _layout_yaxis21;
177
- return series.yaxis === 'y2' && ((layout === null || layout === void 0 ? void 0 : (_layout_yaxis2 = layout.yaxis2) === null || _layout_yaxis2 === void 0 ? void 0 : _layout_yaxis2.anchor) === 'x' || (layout === null || layout === void 0 ? void 0 : (_layout_yaxis21 = layout.yaxis2) === null || _layout_yaxis21 === void 0 ? void 0 : _layout_yaxis21.side) === 'right');
178
- };
179
- const getSecondaryYAxisValues = (data, layout)=>{
180
- var _layout_yaxis2, _layout_yaxis21, _layout_yaxis2_title, _layout_yaxis22;
181
- let containsSecondaryYAxis = false;
182
- let yMinValue;
183
- let yMaxValue;
184
- let allLineSeries = true;
185
- data.forEach((series)=>{
186
- if (usesSecondaryYScale(series, layout)) {
187
- containsSecondaryYAxis = true;
188
- const yValues = series.y;
189
- if (yValues) {
190
- yMinValue = Math.min(...yValues);
191
- yMaxValue = Math.max(...yValues);
192
- }
193
- if (series.type !== 'scatter' || isScatterAreaChart(series)) {
194
- allLineSeries = false;
195
- }
196
- }
197
- });
198
- if (!containsSecondaryYAxis) {
199
- return {};
200
- }
201
- if (!allLineSeries) {
202
- if (typeof yMinValue === 'number') {
203
- yMinValue = Math.min(yMinValue, 0);
204
- }
205
- if (typeof yMaxValue === 'number') {
206
- yMaxValue = Math.max(yMaxValue, 0);
207
- }
208
- }
209
- if (layout === null || layout === void 0 ? void 0 : (_layout_yaxis2 = layout.yaxis2) === null || _layout_yaxis2 === void 0 ? void 0 : _layout_yaxis2.range) {
210
- yMinValue = layout.yaxis2.range[0];
211
- yMaxValue = layout.yaxis2.range[1];
212
- }
213
- return {
214
- secondaryYAxistitle: typeof (layout === null || layout === void 0 ? void 0 : (_layout_yaxis21 = layout.yaxis2) === null || _layout_yaxis21 === void 0 ? void 0 : _layout_yaxis21.title) === 'string' ? layout.yaxis2.title : typeof (layout === null || layout === void 0 ? void 0 : (_layout_yaxis22 = layout.yaxis2) === null || _layout_yaxis22 === void 0 ? void 0 : (_layout_yaxis2_title = _layout_yaxis22.title) === null || _layout_yaxis2_title === void 0 ? void 0 : _layout_yaxis2_title.text) === 'string' ? layout.yaxis2.title.text : undefined,
215
- secondaryYScaleOptions: {
216
- yMinValue,
217
- yMaxValue
218
- }
219
- };
220
- };
221
- export const _getGaugeAxisColor = (colorway, colorwayType, color, colorMap, isDarkTheme)=>{
222
- const extractedColors = extractColor(colorway, colorwayType, color, colorMap, isDarkTheme);
223
- return resolveColor(extractedColors, 0, '', colorMap, colorway, isDarkTheme);
224
- };
225
- export const resolveXAxisPoint = (x, isXYearCategory, isXString, isXDate, isXNumber)=>{
226
- if (x === null || x === undefined) {
227
- return '';
228
- }
229
- if (isXYearCategory) {
230
- return x.toString();
231
- }
232
- if (isXString) {
233
- if (isXDate) {
234
- const date = new Date(x);
235
- return date;
236
- }
237
- if (isXNumber) {
238
- return parseFloat(x);
239
- }
240
- return x;
241
- }
242
- return x;
243
- };
244
- /**
245
- * Formats text values according to the texttemplate specification
246
- * Supports D3 format specifiers within %{text:format} patterns
247
- * @param textValue The raw text value to format
248
- * @param textTemplate The template string (e.g., "%{text:.1f}%", "%{text:.2%}", "%{text:,.0f}")
249
- * @param index Optional index for array-based templates
250
- * @returns Formatted text string
251
- *
252
- * Examples:
253
- * - "%{text:.1f}%" → Formats number with 1 decimal place and adds % suffix
254
- * - "%{text:.2%}" → Formats as percentage with 2 decimal places
255
- * - "%{text:,.0f}" → Formats with thousands separator and no decimals
256
- * - "%{text:$,.2f}" → Formats as currency with thousands separator and 2 decimals
257
- */ const formatTextWithTemplate = (textValue, textTemplate, index)=>{
258
- if (!textTemplate) {
259
- return String(textValue);
260
- }
261
- const numVal = typeof textValue === 'number' ? textValue : parseFloat(String(textValue));
262
- if (isNaN(numVal)) {
263
- return String(textValue);
264
- }
265
- const template = typeof textTemplate === 'string' ? textTemplate : textTemplate[index || 0] || '';
266
- // Match Plotly's texttemplate pattern: %{text:format} or %{text}
267
- // Can be followed by any literal text like %, $, etc.
268
- const plotlyPattern = /%\{text(?::([^}]+))?\}(.*)$/;
269
- const match = template.match(plotlyPattern);
270
- if (match) {
271
- const formatSpec = match[1]; // The format specifier (e.g., ".1f", ".2%", ",.0f") or undefined
272
- const suffix = match[2]; // Any text after the closing brace (e.g., "%", " units")
273
- // If no format specifier is provided (e.g., %{text}%), try to infer from suffix
274
- if (!formatSpec) {
275
- // Check if suffix starts with % - assume simple percentage with 1 decimal
276
- if (suffix.startsWith('%')) {
277
- return `${numVal.toFixed(1)}${suffix}`;
278
- }
279
- // No format specifier, just return the number with the suffix
280
- return `${numVal}${suffix}`;
281
- }
282
- try {
283
- // Use D3 format function to apply the format specifier
284
- const formatter = d3Format(formatSpec);
285
- const formattedValue = formatter(numVal);
286
- return `${formattedValue}${suffix}`;
287
- } catch (error) {
288
- // Try to extract precision for basic fallback
289
- const precisionMatch = formatSpec.match(/\.(\d+)[f%]/);
290
- const precision = precisionMatch ? parseInt(precisionMatch[1], 10) : 2;
291
- // Check if it's a percentage format
292
- if (formatSpec.includes('%')) {
293
- return `${(numVal * 100).toFixed(precision)}%${suffix}`;
294
- }
295
- return `${numVal.toFixed(precision)}${suffix}`;
296
- }
297
- }
298
- return String(textValue);
299
- };
300
- /**
301
- * Extracts unique X-axis categories from Plotly data traces
302
- * @param data Array of Plotly data traces
303
- * @returns Array of unique x values
304
- */ const extractXCategories = (data)=>{
305
- return Array.from(new Set((data !== null && data !== void 0 ? data : []).flatMap((trace)=>{
306
- const xData = trace.x;
307
- if (!xData) {
308
- return [];
309
- }
310
- if (Array.isArray(xData)) {
311
- return xData.flat().map((x)=>{
312
- return x;
313
- });
314
- }
315
- return [];
316
- }).filter((x)=>x !== undefined && x !== null)));
317
- };
318
- /**
319
- * Checks if a key should be ignored during normalization
320
- * @param key The key to check
321
- * @returns true if the key should be ignored
322
- */ const shouldIgnoreKey = (key)=>{
323
- const lowerKey = key.toLowerCase();
324
- if (lowerKey.includes('style') || lowerKey === 'style') {
325
- return true;
326
- }
327
- // Use regex to match common CSS property patterns
328
- // (color, fill, stroke, border, background, font, shadow, outline, etc.)
329
- const cssKeyRegex = new RegExp('^(color|fill|stroke|border|background|font|shadow|outline|margin|padding|gap|align|justify|display|flex|grid|' + 'text|line|letter|word|vertical|horizontal|overflow|position|top|right|bottom|left|zindex|z-index|opacity|' + 'filter|clip|cursor|resize|transition|animation|transform|box|column|row|direction|visibility|' + 'content|width|height|aspect|image|user|pointer|caret|scroll|%)|(-webkit-|-moz-|-ms-|-o-)', 'i');
330
- if (cssKeyRegex.test(lowerKey)) {
331
- return true;
332
- }
333
- return false;
334
- };
335
- /**
336
- * Flattens a nested object into a single level object with dot notation keys
337
- * @param obj Object to flatten
338
- * @param prefix Optional prefix for keys
339
- * @returns Flattened object
340
- */ const flattenObject = (obj, prefix = '')=>{
341
- const flattened = {};
342
- for(const key in obj){
343
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
344
- const newKey = prefix ? `${prefix}.${key}` : key;
345
- const value = obj[key];
346
- if (typeof value === 'object' && value !== null && !Array.isArray(value) && !(value instanceof Date)) {
347
- // Recursively flatten nested objects
348
- Object.assign(flattened, flattenObject(value, newKey));
349
- } else {
350
- flattened[newKey] = value;
351
- }
352
- }
353
- }
354
- return flattened;
355
- };
356
- const encodeHtmlEntities = (value)=>value.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#39;');
357
- const toFiniteNumber = (value)=>{
358
- if (value === undefined || value === null) {
359
- return undefined;
360
- }
361
- const numeric = typeof value === 'number' ? value : Number(value);
362
- return Number.isFinite(numeric) ? numeric : undefined;
363
- };
364
- /**
365
- * Parses Plotly axis references (e.g. `x`, `x2`, `xaxis2`, `paper`, `pixel`, `x domain`) into a ref type + axis id.
366
- */ const parseAxisRef = (ref, axis)=>{
367
- if (!ref) {
368
- return {
369
- refType: 'axis',
370
- axisId: 1
371
- };
372
- }
373
- const normalized = ref.toLowerCase().trim();
374
- if (normalized === 'pixel') {
375
- return {
376
- refType: 'pixel',
377
- axisId: 1
378
- };
379
- }
380
- if (normalized === 'paper') {
381
- return {
382
- refType: 'relative',
383
- axisId: 1
384
- };
385
- }
386
- if (normalized.endsWith(' domain')) {
387
- return normalized.startsWith(axis) ? {
388
- refType: 'relative',
389
- axisId: 1
390
- } : {
391
- refType: undefined,
392
- axisId: 1
393
- };
394
- }
395
- const match = normalized.match(/^([xy])(axis)?(\d*)$/);
396
- if (!match || match[1] !== axis) {
397
- return {
398
- refType: undefined,
399
- axisId: 1
400
- };
401
- }
402
- const suffix = match[3];
403
- if (!suffix || suffix === '1') {
404
- return {
405
- refType: 'axis',
406
- axisId: 1
407
- };
408
- }
409
- const parsed = Number(suffix);
410
- return {
411
- refType: 'axis',
412
- axisId: Number.isFinite(parsed) && parsed >= 1 ? parsed : 1
413
- };
414
- };
415
- /**
416
- * Converts Plotly's bottom-origin relative Y coordinate into the SVG top-origin space used by our overlay.
417
- */ const transformRelativeYForChart = (value)=>{
418
- if (value === undefined) {
419
- return undefined;
420
- }
421
- if (!Number.isFinite(value)) {
422
- return undefined;
423
- }
424
- return 1 - value;
425
- };
426
- const mapHorizontalAlign = (anchor)=>{
427
- switch((anchor !== null && anchor !== void 0 ? anchor : '').toLowerCase()){
428
- case 'left':
429
- return 'start';
430
- case 'center':
431
- return 'center';
432
- case 'right':
433
- return 'end';
434
- default:
435
- return undefined;
436
- }
437
- };
438
- const mapVerticalAlign = (anchor)=>{
439
- switch((anchor !== null && anchor !== void 0 ? anchor : '').toLowerCase()){
440
- case 'top':
441
- return 'top';
442
- case 'middle':
443
- return 'middle';
444
- case 'bottom':
445
- return 'bottom';
446
- default:
447
- return undefined;
448
- }
449
- };
450
- const appendPx = (value)=>{
451
- if (value === undefined || value === null) {
452
- return undefined;
453
- }
454
- if (typeof value === 'string') {
455
- return value;
456
- }
457
- if (typeof value === 'number' && Number.isFinite(value)) {
458
- return `${value}px`;
459
- }
460
- return undefined;
461
- };
462
- /**
463
- * Maps Plotly's axis reference string to one of our coordinate interpretation modes (axis, relative, or pixel).
464
- */ const resolveRefType = (ref, axis)=>{
465
- if (!ref) {
466
- return 'axis';
467
- }
468
- const parsed = parseAxisRef(ref, axis);
469
- if (parsed.refType !== 'axis') {
470
- return parsed.refType;
471
- }
472
- const normalized = (ref !== null && ref !== void 0 ? ref : '').toLowerCase().trim();
473
- const match = normalized.match(/^([xy])(\d*)$/);
474
- return match && match[1] === axis ? 'axis' : undefined;
475
- };
476
- /**
477
- * Retrieves the appropriate axis layout section from Plotly's layout given an axis reference alias.
478
- */ const getAxisLayoutByRef = (layout, ref, axis)=>{
479
- if (!layout) {
480
- return undefined;
481
- }
482
- const defaultAxisKey = `${axis}axis`;
483
- const { refType, axisId } = parseAxisRef(ref, axis);
484
- if (refType !== 'axis' || axisId === 1) {
485
- return layout[defaultAxisKey];
486
- }
487
- const axisKey = `${axis}axis${axisId}`;
488
- return layout[axisKey];
489
- };
490
- const convertAnnotationDataValue = (value, axisType)=>{
491
- if (value === undefined || value === null) {
492
- return undefined;
493
- }
494
- if (axisType === 'date') {
495
- const dateValue = value instanceof Date ? value : new Date(value);
496
- return Number.isNaN(dateValue.getTime()) ? undefined : dateValue;
497
- }
498
- if (axisType === 'linear' || axisType === 'log') {
499
- if (typeof value === 'number') {
500
- return Number.isFinite(value) ? value : undefined;
501
- }
502
- const numeric = Number(value);
503
- return Number.isFinite(numeric) ? numeric : undefined;
504
- }
505
- // For category-like axes, preserve raw strings (and avoid date parsing heuristics).
506
- if (value instanceof Date) {
507
- return value;
508
- }
509
- if (typeof value === 'number' || typeof value === 'string') {
510
- return value;
511
- }
512
- return undefined;
513
- };
514
- const createAnnotationId = (text, index)=>{
515
- const normalized = text.replace(/\s+/g, ' ').trim();
516
- if (normalized) {
517
- const slug = normalized.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 32);
518
- if (slug) {
519
- return `annotation-${index}-${slug}`;
520
- }
521
- }
522
- return `annotation-${index}`;
523
- };
524
- const DEFAULT_ARROW_OFFSET = -40;
525
- const mapArrowsideToArrow = (annotation)=>{
526
- let includeStart = false;
527
- let includeEnd = false;
528
- const arrowSide = typeof (annotation === null || annotation === void 0 ? void 0 : annotation.arrowside) === 'string' ? annotation === null || annotation === void 0 ? void 0 : annotation.arrowside.toLowerCase() : undefined;
529
- if (arrowSide) {
530
- includeStart = arrowSide.includes('start');
531
- includeEnd = arrowSide.includes('end');
532
- }
533
- const endHead = toFiniteNumber(annotation === null || annotation === void 0 ? void 0 : annotation.arrowhead);
534
- const startHead = toFiniteNumber(annotation.startarrowhead);
535
- if (endHead !== undefined && endHead > 0) {
536
- includeEnd = true;
537
- }
538
- if (startHead !== undefined && startHead > 0) {
539
- includeStart = true;
540
- }
541
- if (includeStart && includeEnd) {
542
- return 'both';
543
- }
544
- if (includeStart) {
545
- return 'start';
546
- }
547
- if (includeEnd) {
548
- return 'end';
549
- }
550
- return 'none';
551
- };
552
- const mapArrowDashToPattern = (value)=>{
553
- if (!value) {
554
- return undefined;
555
- }
556
- const normalized = value.trim().toLowerCase();
557
- switch(normalized){
558
- case 'solid':
559
- return undefined;
560
- case 'dot':
561
- return '1, 5';
562
- case 'dash':
563
- return '5, 5';
564
- case 'longdash':
565
- return '10, 5';
566
- case 'dashdot':
567
- return '5, 5, 1, 5';
568
- case 'longdashdot':
569
- return '10, 5, 1, 5';
570
- default:
571
- if (/^\d+(\s|,)*\d*$/.test(normalized.replace(/\s+/g, ' '))) {
572
- return normalized.replace(/\s+/g, ' ');
573
- }
574
- return value;
575
- }
576
- };
577
- const mapRefTypeToCoordinateType = (refType)=>{
578
- return refType === 'axis' ? 'data' : refType;
579
- };
580
- const normalizeCoordinateValueForType = (coordinateType, value)=>{
581
- if (coordinateType === 'data') {
582
- return value;
583
- }
584
- return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
585
- };
586
- const getAnnotationCoordinateValue = (axis, refType, annotation, layout)=>{
587
- if (refType === 'axis') {
588
- const axisRef = axis === 'x' ? annotation === null || annotation === void 0 ? void 0 : annotation.xref : annotation === null || annotation === void 0 ? void 0 : annotation.yref;
589
- const axisLayout = getAxisLayoutByRef(layout, axisRef, axis);
590
- const rawValue = axis === 'x' ? annotation === null || annotation === void 0 ? void 0 : annotation.x : annotation === null || annotation === void 0 ? void 0 : annotation.y;
591
- var _axisLayout_type;
592
- const axisType = (_axisLayout_type = axisLayout === null || axisLayout === void 0 ? void 0 : axisLayout.type) !== null && _axisLayout_type !== void 0 ? _axisLayout_type : 'category';
593
- return convertAnnotationDataValue(rawValue, axisType);
594
- }
595
- const numericValue = toFiniteNumber(axis === 'x' ? annotation === null || annotation === void 0 ? void 0 : annotation.x : annotation === null || annotation === void 0 ? void 0 : annotation.y);
596
- if (numericValue === undefined) {
597
- return undefined;
598
- }
599
- if (refType === 'relative') {
600
- return axis === 'y' ? transformRelativeYForChart(numericValue) : numericValue;
601
- }
602
- return numericValue;
603
- };
604
- /**
605
- * Converts a Plotly annotation definition into the internal `ChartAnnotation` format, translating coordinates,
606
- * layout alignment, styling, and connector metadata while skipping unsupported configurations.
607
- */ const convertPlotlyAnnotation = (annotation, layout, index)=>{
608
- if (!annotation || annotation.visible === false) {
609
- return undefined;
610
- }
611
- const xRefType = resolveRefType(annotation.xref, 'x');
612
- const yRefType = resolveRefType(annotation.yref, 'y');
613
- if (!xRefType || !yRefType) {
614
- return undefined;
615
- }
616
- const xValue = getAnnotationCoordinateValue('x', xRefType, annotation, layout);
617
- const yValue = getAnnotationCoordinateValue('y', yRefType, annotation, layout);
618
- if (xValue === undefined || yValue === undefined) {
619
- return undefined;
620
- }
621
- const xCoordinateType = mapRefTypeToCoordinateType(xRefType);
622
- const yCoordinateType = mapRefTypeToCoordinateType(yRefType);
623
- const normalizedX = normalizeCoordinateValueForType(xCoordinateType, xValue);
624
- const normalizedY = normalizeCoordinateValueForType(yCoordinateType, yValue);
625
- if (normalizedX === undefined || normalizedY === undefined) {
626
- return undefined;
627
- }
628
- const yRefNormalized = typeof annotation.yref === 'string' ? annotation.yref.toLowerCase() : undefined;
629
- const yAxisProps = yCoordinateType === 'data' && yRefNormalized === 'y2' ? {
630
- yAxis: 'secondary'
631
- } : undefined;
632
- let coordinates;
633
- if (xCoordinateType === 'data' && yCoordinateType === 'data') {
634
- coordinates = {
635
- type: 'data',
636
- x: normalizedX,
637
- y: normalizedY,
638
- ...yAxisProps !== null && yAxisProps !== void 0 ? yAxisProps : {}
639
- };
640
- } else if (xCoordinateType === 'relative' && yCoordinateType === 'relative') {
641
- coordinates = {
642
- type: 'relative',
643
- x: normalizedX,
644
- y: normalizedY
645
- };
646
- } else if (xCoordinateType === 'pixel' && yCoordinateType === 'pixel') {
647
- coordinates = {
648
- type: 'pixel',
649
- x: normalizedX,
650
- y: normalizedY
651
- };
652
- } else {
653
- coordinates = {
654
- type: 'mixed',
655
- xCoordinateType,
656
- yCoordinateType,
657
- x: normalizedX,
658
- y: normalizedY,
659
- ...yAxisProps !== null && yAxisProps !== void 0 ? yAxisProps : {}
660
- };
661
- }
662
- const textValue = annotation.text;
663
- const rawText = textValue === undefined || textValue === null ? '' : String(textValue);
664
- const encodedText = encodeHtmlEntities(rawText);
665
- const chartAnnotation = {
666
- id: createAnnotationId(encodedText, index),
667
- text: encodedText,
668
- coordinates
669
- };
670
- const layoutProps = {};
671
- const styleProps = {};
672
- const showArrow = annotation.showarrow === undefined ? false : !!annotation.showarrow;
673
- const clipOnAxis = annotation.cliponaxis;
674
- if (clipOnAxis !== undefined) {
675
- layoutProps.clipToBounds = !!clipOnAxis;
676
- } else if (coordinates.type === 'data') {
677
- layoutProps.clipToBounds = true;
678
- }
679
- const horizontalAlign = mapHorizontalAlign(annotation.xanchor);
680
- if (horizontalAlign) {
681
- layoutProps.align = horizontalAlign;
682
- }
683
- if (!layoutProps.align) {
684
- const alignProp = mapHorizontalAlign(annotation.align);
685
- if (alignProp) {
686
- layoutProps.align = alignProp;
687
- }
688
- }
689
- const verticalAlign = mapVerticalAlign(annotation.yanchor);
690
- if (verticalAlign) {
691
- layoutProps.verticalAlign = verticalAlign;
692
- }
693
- if (!layoutProps.verticalAlign) {
694
- const valignProp = mapVerticalAlign(annotation.valign);
695
- if (valignProp) {
696
- layoutProps.verticalAlign = valignProp;
697
- }
698
- }
699
- const offsetXComponents = [];
700
- let hasExplicitOffset = false;
701
- const ax = toFiniteNumber(annotation.ax);
702
- const axRef = typeof annotation.axref === 'string' ? annotation.axref.toLowerCase() : undefined;
703
- if (ax !== undefined && (axRef === undefined || axRef === 'pixel')) {
704
- offsetXComponents.push(ax);
705
- hasExplicitOffset = true;
706
- }
707
- const xShift = toFiniteNumber(annotation.xshift);
708
- if (xShift !== undefined) {
709
- offsetXComponents.push(xShift);
710
- hasExplicitOffset = true;
711
- }
712
- if (offsetXComponents.length > 0) {
713
- const offsetX = offsetXComponents.reduce((sum, value)=>sum + value, 0);
714
- if (offsetX !== 0) {
715
- layoutProps.offsetX = offsetX;
716
- }
717
- }
718
- const offsetYComponents = [];
719
- const ay = toFiniteNumber(annotation.ay);
720
- const ayRef = typeof annotation.ayref === 'string' ? annotation.ayref.toLowerCase() : undefined;
721
- if (ay !== undefined && (ayRef === undefined || ayRef === 'pixel')) {
722
- offsetYComponents.push(ay);
723
- hasExplicitOffset = true;
724
- }
725
- const yShift = toFiniteNumber(annotation.yshift);
726
- if (yShift !== undefined) {
727
- offsetYComponents.push(yShift);
728
- hasExplicitOffset = true;
729
- }
730
- if (offsetYComponents.length > 0) {
731
- const offsetY = offsetYComponents.reduce((sum, value)=>sum + value, 0);
732
- if (offsetY !== 0) {
733
- layoutProps.offsetY = offsetY;
734
- }
735
- }
736
- if (showArrow && !hasExplicitOffset && layoutProps.offsetY === undefined) {
737
- layoutProps.offsetY = DEFAULT_ARROW_OFFSET;
738
- }
739
- const maxWidth = toFiniteNumber(annotation.width);
740
- if (maxWidth !== undefined) {
741
- layoutProps.maxWidth = maxWidth;
742
- }
743
- if (annotation.bgcolor) {
744
- styleProps.backgroundColor = annotation.bgcolor;
745
- }
746
- if (annotation.bordercolor) {
747
- styleProps.borderColor = annotation.bordercolor;
748
- }
749
- const borderWidth = toFiniteNumber(annotation.borderwidth);
750
- if (borderWidth !== undefined) {
751
- styleProps.borderWidth = borderWidth;
752
- }
753
- const borderPad = appendPx(annotation.borderpad);
754
- if (borderPad) {
755
- styleProps.padding = borderPad;
756
- }
757
- const opacity = toFiniteNumber(annotation.opacity);
758
- if (opacity !== undefined) {
759
- styleProps.opacity = opacity;
760
- }
761
- if (annotation.font) {
762
- const font = annotation.font;
763
- if (font === null || font === void 0 ? void 0 : font.color) {
764
- styleProps.textColor = font.color;
765
- }
766
- const fontSize = appendPx(font === null || font === void 0 ? void 0 : font.size);
767
- if (fontSize) {
768
- styleProps.fontSize = fontSize;
769
- }
770
- if (font === null || font === void 0 ? void 0 : font.weight) {
771
- styleProps.fontWeight = font.weight;
772
- }
773
- }
774
- const textAngle = annotation === null || annotation === void 0 ? void 0 : annotation.textangle;
775
- if (typeof textAngle === 'number' && !Number.isNaN(textAngle)) {
776
- styleProps.rotation = textAngle;
777
- } else if (typeof textAngle === 'string' && textAngle.toLowerCase() !== 'auto') {
778
- const parsedAngle = Number(textAngle);
779
- if (!Number.isNaN(parsedAngle)) {
780
- styleProps.rotation = parsedAngle;
781
- }
782
- }
783
- if (Object.keys(layoutProps).length > 0) {
784
- chartAnnotation.layout = layoutProps;
785
- }
786
- if (Object.keys(styleProps).length > 0) {
787
- chartAnnotation.style = styleProps;
788
- }
789
- if (showArrow) {
790
- var _annotation_arrowcolor;
791
- const arrowColor = (_annotation_arrowcolor = annotation.arrowcolor) !== null && _annotation_arrowcolor !== void 0 ? _annotation_arrowcolor : styleProps.textColor;
792
- const arrowWidth = toFiniteNumber(annotation.arrowwidth);
793
- const endPadding = toFiniteNumber(annotation.standoff);
794
- const startPadding = toFiniteNumber(annotation.startstandoff);
795
- const dashPattern = mapArrowDashToPattern(annotation.arrowdash);
796
- chartAnnotation.connector = {
797
- ...arrowColor ? {
798
- strokeColor: arrowColor
799
- } : {},
800
- ...arrowWidth !== undefined ? {
801
- strokeWidth: arrowWidth
802
- } : {},
803
- ...endPadding !== undefined ? {
804
- endPadding: Math.max(endPadding, 0)
805
- } : {},
806
- ...startPadding !== undefined ? {
807
- startPadding: Math.max(startPadding, 0)
808
- } : {},
809
- ...dashPattern ? {
810
- dashArray: dashPattern
811
- } : {},
812
- arrow: mapArrowsideToArrow(annotation)
813
- };
814
- }
815
- return chartAnnotation;
816
- };
817
- const getChartAnnotationsFromLayout = (data, layout, isMultiPlot)=>{
818
- if (isMultiPlot || !(layout === null || layout === void 0 ? void 0 : layout.annotations)) {
819
- return undefined;
820
- }
821
- // Infer axis types when they are not explicitly set.
822
- // This is needed so annotation coordinate parsing can correctly treat values as 'date' vs 'category'
823
- // (for example, bar chart category axes with date-like strings).
824
- const inferredLayout = (()=>{
825
- if (!data || !isArrayOrTypedArray(data) || data.length === 0) {
826
- return layout;
827
- }
828
- const valuesByAxisKey = new Map();
829
- const axesExpectingCategories = new Set();
830
- data.forEach((series)=>{
831
- const trace = series;
832
- const axisIds = getAxisIds(trace);
833
- if (trace.type === 'bar') {
834
- const categoryAxisLetter = trace.orientation === 'h' ? 'y' : 'x';
835
- axesExpectingCategories.add(getAxisKey(categoryAxisLetter, axisIds[categoryAxisLetter]));
836
- }
837
- [
838
- 'x',
839
- 'y'
840
- ].forEach((axLetter)=>{
841
- const coords = trace[axLetter];
842
- if (!coords || !isArrayOrTypedArray(coords)) {
843
- return;
844
- }
845
- const axisKey = getAxisKey(axLetter, axisIds[axLetter]);
846
- var _valuesByAxisKey_get;
847
- const existing = (_valuesByAxisKey_get = valuesByAxisKey.get(axisKey)) !== null && _valuesByAxisKey_get !== void 0 ? _valuesByAxisKey_get : [];
848
- coords.forEach((val)=>{
849
- if (!isInvalidValue(val)) {
850
- existing.push(val);
851
- }
852
- });
853
- valuesByAxisKey.set(axisKey, existing);
854
- });
855
- });
856
- let nextLayout;
857
- valuesByAxisKey.forEach((values, axisKey)=>{
858
- const currentAxis = layout === null || layout === void 0 ? void 0 : layout[axisKey];
859
- const currentType = currentAxis === null || currentAxis === void 0 ? void 0 : currentAxis.type;
860
- if ([
861
- 'linear',
862
- 'log',
863
- 'date',
864
- 'category'
865
- ].includes(currentType !== null && currentType !== void 0 ? currentType : '')) {
866
- return;
867
- }
868
- let inferredType;
869
- if (axesExpectingCategories.has(axisKey) || isYearArray(values)) {
870
- inferredType = 'category';
871
- } else if (isDateArray(values)) {
872
- inferredType = 'date';
873
- }
874
- if (!inferredType) {
875
- return;
876
- }
877
- if (!nextLayout) {
878
- nextLayout = {
879
- ...layout
880
- };
881
- }
882
- nextLayout[axisKey] = {
883
- ...currentAxis !== null && currentAxis !== void 0 ? currentAxis : {},
884
- type: inferredType
885
- };
886
- });
887
- return nextLayout !== null && nextLayout !== void 0 ? nextLayout : layout;
888
- })();
889
- const annotationsArray = Array.isArray(layout.annotations) ? layout.annotations : [
890
- layout.annotations
891
- ];
892
- const converted = annotationsArray.map((annotation, index)=>convertPlotlyAnnotation(annotation, inferredLayout, index)).filter((annotation)=>annotation !== undefined);
893
- return converted.length > 0 ? converted : undefined;
894
- };
895
- /**
896
- * Normalizes an array of objects by flattening nested structures and creating grouped data
897
- * Uses json_normalize approach with D3 color detection and filtering
898
- * @param data Array of objects to normalize
899
- * @returns Object containing traces for grouped vertical bar chart
900
- */ export const normalizeObjectArrayForGVBC = (data, xLabels)=>{
901
- if (!data || data.length === 0) {
902
- return {
903
- traces: [],
904
- x: []
905
- };
906
- }
907
- // Use provided xLabels if available, otherwise default to Item 1, Item 2, ...
908
- const x = xLabels && xLabels.length === data.length ? xLabels : data.map((_, index)=>`Item ${index + 1}`);
909
- // First, flatten all objects and collect all unique keys, excluding style keys
910
- const flattenedObjects = data.map((item, index)=>{
911
- if (typeof item === 'object' && item !== null) {
912
- const flattened = flattenObject(item);
913
- // Only keep keys where the value is numeric (number or numeric string) and not a style key
914
- const filtered = {};
915
- Object.keys(flattened).forEach((key)=>{
916
- const value = flattened[key];
917
- if (!shouldIgnoreKey(key) && (typeof value === 'number' || typeof value === 'string' && isNumber(value))) {
918
- filtered[key] = value;
919
- }
920
- });
921
- return filtered;
922
- } else if (typeof item === 'number' || typeof item === 'string' && isNumber(item)) {
923
- // Only keep primitive numeric values
924
- return {
925
- [x[index] || `item_${index}`]: item
926
- };
927
- } else {
928
- // Non-numeric primitive, ignore by returning empty object
929
- return {};
930
- }
931
- });
932
- // Collect all unique keys across all objects
933
- const allKeys = new Set();
934
- flattenedObjects.forEach((obj)=>{
935
- Object.keys(obj).forEach((key)=>allKeys.add(key));
936
- });
937
- // Create traces for each key (property)
938
- const traces = [];
939
- allKeys.forEach((key)=>{
940
- const yValues = [];
941
- let hasValidData = false;
942
- let isNumericData = false;
943
- flattenedObjects.forEach((obj, index)=>{
944
- const value = obj[key];
945
- if (typeof value === 'number') {
946
- yValues.push(value);
947
- hasValidData = true;
948
- isNumericData = true;
949
- } else if (typeof value === 'string' && isNumber(value)) {
950
- yValues.push(parseFloat(value));
951
- hasValidData = true;
952
- isNumericData = true;
953
- }
954
- });
955
- // Only create trace if we have valid numeric data
956
- if (hasValidData && isNumericData) {
957
- const trace = {
958
- type: 'bar',
959
- name: key,
960
- x,
961
- y: yValues
962
- };
963
- traces.push(trace);
964
- }
965
- });
966
- return {
967
- traces,
968
- x
969
- };
970
- };
971
- export const transformPlotlyJsonToAnnotationChartProps = (input, isMultiPlot, _colorMap, _colorwayType, _isDarkTheme)=>{
972
- var _layoutWithMeta_meta, _input_layout, _input_layout1, _input_layout2, _input_layout3, _input_layout_font, _input_layout4, _input_layout_font1, _input_layout5, _input_layout6;
973
- var _getChartAnnotationsFromLayout;
974
- const annotations = (_getChartAnnotationsFromLayout = getChartAnnotationsFromLayout(input.data, input.layout, isMultiPlot)) !== null && _getChartAnnotationsFromLayout !== void 0 ? _getChartAnnotationsFromLayout : [];
975
- const titles = getTitles(input.layout);
976
- const layoutTitle = titles.chartTitle || undefined;
977
- const layoutWithMeta = input.layout;
978
- const description = typeof (layoutWithMeta === null || layoutWithMeta === void 0 ? void 0 : (_layoutWithMeta_meta = layoutWithMeta.meta) === null || _layoutWithMeta_meta === void 0 ? void 0 : _layoutWithMeta_meta.description) === 'string' ? layoutWithMeta.meta.description : undefined;
979
- const width = typeof ((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width) === 'number' ? input.layout.width : undefined;
980
- const height = typeof ((_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.height) === 'number' ? input.layout.height : undefined;
981
- const paperBackgroundColor = typeof ((_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.paper_bgcolor) === 'string' ? input.layout.paper_bgcolor : undefined;
982
- const plotBackgroundColor = typeof ((_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : _input_layout3.plot_bgcolor) === 'string' ? input.layout.plot_bgcolor : undefined;
983
- const fontColor = typeof ((_input_layout4 = input.layout) === null || _input_layout4 === void 0 ? void 0 : (_input_layout_font = _input_layout4.font) === null || _input_layout_font === void 0 ? void 0 : _input_layout_font.color) === 'string' ? input.layout.font.color : undefined;
984
- const fontFamily = typeof ((_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : (_input_layout_font1 = _input_layout5.font) === null || _input_layout_font1 === void 0 ? void 0 : _input_layout_font1.family) === 'string' ? input.layout.font.family : undefined;
985
- const margin = (_input_layout6 = input.layout) === null || _input_layout6 === void 0 ? void 0 : _input_layout6.margin;
986
- return {
987
- annotations,
988
- chartTitle: layoutTitle,
989
- description,
990
- width,
991
- height,
992
- paperBackgroundColor,
993
- plotBackgroundColor,
994
- fontColor,
995
- fontFamily,
996
- margin
997
- };
998
- };
999
- export const transformPlotlyJsonToDonutProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
1000
- var _input_layout, _input_layout_template_layout, _input_layout_template, _input_layout1, _input_layout2, _firstData_marker, _input_layout3, _input_layout4, _input_layout5, _input_layout6;
1001
- const firstData = input.data[0];
1002
- var _input_layout_piecolorway, _input_layout_piecolorway1;
1003
- // extract colors for each series only once
1004
- // use piecolorway if available
1005
- // otherwise, default to colorway from template
1006
- const colors = extractColor((_input_layout_piecolorway = (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.piecolorway) !== null && _input_layout_piecolorway !== void 0 ? _input_layout_piecolorway : (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_template = _input_layout1.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_input_layout_piecolorway1 = (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.piecolorway) !== null && _input_layout_piecolorway1 !== void 0 ? _input_layout_piecolorway1 : firstData === null || firstData === void 0 ? void 0 : (_firstData_marker = firstData.marker) === null || _firstData_marker === void 0 ? void 0 : _firstData_marker.colors, colorMap, isDarkTheme, true);
1007
- const mapLegendToDataPoint = {};
1008
- // clear colorMap for donut chart to reassign colors as the colorMap initially gets assigned by
1009
- // getAllupLegendsProps function without sorting labels by value
1010
- colorMap.current.clear();
1011
- // Sort labels by value descending before mapping
1012
- if (firstData.labels && firstData.values) {
1013
- var _firstData_marker1;
1014
- const markerColors = ((_firstData_marker1 = firstData.marker) === null || _firstData_marker1 === void 0 ? void 0 : _firstData_marker1.colors) || undefined;
1015
- const hasMarkerColors = Array.isArray(markerColors) && markerColors.length >= firstData.labels.length;
1016
- const labelValuePairs = firstData.labels.map((label, index)=>({
1017
- label,
1018
- value: getNumberAtIndexOrDefault(firstData.values, index),
1019
- index,
1020
- color: hasMarkerColors ? markerColors[index] : undefined
1021
- }));
1022
- // Filter out invalid values
1023
- const validPairs = labelValuePairs.filter((pair)=>!isInvalidValue(pair.value));
1024
- // Sort descending by value; when marker colors are present, keep color attached to the label
1025
- validPairs.sort((a, b)=>b.value - a.value);
1026
- validPairs.forEach((pair, sortedIdx)=>{
1027
- var _input_layout, _input_layout_template_layout, _input_layout_template, _input_layout1;
1028
- const legend = `${pair.label}`;
1029
- var _input_layout_piecolorway, _pair_color;
1030
- const color = (_pair_color = pair.color) !== null && _pair_color !== void 0 ? _pair_color : resolveColor(colors, sortedIdx, legend, colorMap, (_input_layout_piecolorway = (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.piecolorway) !== null && _input_layout_piecolorway !== void 0 ? _input_layout_piecolorway : (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_template = _input_layout1.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, isDarkTheme, true);
1031
- if (!mapLegendToDataPoint[legend]) {
1032
- mapLegendToDataPoint[legend] = {
1033
- legend,
1034
- data: pair.value,
1035
- color
1036
- };
1037
- } else {
1038
- mapLegendToDataPoint[legend].data += pair.value;
1039
- }
1040
- });
1041
- }
1042
- var _input_layout_width;
1043
- const width = (_input_layout_width = (_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : _input_layout3.width) !== null && _input_layout_width !== void 0 ? _input_layout_width : 440;
1044
- var _input_layout_height;
1045
- const height = (_input_layout_height = (_input_layout4 = input.layout) === null || _input_layout4 === void 0 ? void 0 : _input_layout4.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 220;
1046
- const hideLabels = firstData.textinfo ? ![
1047
- 'value',
1048
- 'percent',
1049
- 'label+percent',
1050
- 'percent+label'
1051
- ].includes(firstData.textinfo) : false;
1052
- const donutMarginHorizontal = hideLabels ? 0 : 80;
1053
- const donutMarginVertical = 40 + (hideLabels ? 0 : 40);
1054
- const innerRadius = firstData.hole ? firstData.hole * (Math.min(width - donutMarginHorizontal, height - donutMarginVertical) / 2) : MIN_DONUT_RADIUS;
1055
- const { chartTitle, titleStyles } = getTitles(input.layout);
1056
- // Build anticlockwise order by keeping the first item, reversing the rest
1057
- const legends = Object.keys(mapLegendToDataPoint);
1058
- const reorderedEntries = legends.length > 1 ? [
1059
- [
1060
- legends[0],
1061
- mapLegendToDataPoint[legends[0]]
1062
- ],
1063
- ...legends.slice(1).reverse().map((key)=>[
1064
- key,
1065
- mapLegendToDataPoint[key]
1066
- ])
1067
- ] : legends.map((key)=>[
1068
- key,
1069
- mapLegendToDataPoint[key]
1070
- ]);
1071
- return {
1072
- data: {
1073
- chartTitle,
1074
- chartData: reorderedEntries.map(([, v])=>v)
1075
- },
1076
- hideLegend: isMultiPlot || ((_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : _input_layout5.showlegend) === false,
1077
- width: (_input_layout6 = input.layout) === null || _input_layout6 === void 0 ? void 0 : _input_layout6.width,
1078
- height,
1079
- innerRadius,
1080
- hideLabels,
1081
- showLabelsInPercent: firstData.textinfo ? [
1082
- 'percent',
1083
- 'label+percent',
1084
- 'percent+label'
1085
- ].includes(firstData.textinfo) : true,
1086
- roundCorners: true,
1087
- order: 'sorted',
1088
- ...titleStyles ? {
1089
- titleStyles
1090
- } : {}
1091
- };
1092
- };
1093
- export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme, fallbackVSBC)=>{
1094
- var _input_layout, _input_layout1, _input_layout2;
1095
- const mapXToDataPoints = {};
1096
- let yMaxValue = 0;
1097
- let yMinValue = 0;
1098
- const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
1099
- const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
1100
- let colorScale = undefined;
1101
- const yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
1102
- const resolveXValue = getAxisValueResolver(getAxisType(input.data, getAxisObjects(input.data, input.layout).x));
1103
- input.data.forEach((series, index1)=>{
1104
- var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _input_layout_template_layout1, _input_layout_template1, _input_layout1, _series_line;
1105
- colorScale = createColorScale(input.layout, series, colorScale);
1106
- // extract bar colors for each series only once
1107
- const extractedBarColors = extractColor((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color, colorMap, isDarkTheme);
1108
- // extract line colors for each series only once
1109
- const extractedLineColors = extractColor((_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_template1 = _input_layout1.template) === null || _input_layout_template1 === void 0 ? void 0 : (_input_layout_template_layout1 = _input_layout_template1.layout) === null || _input_layout_template_layout1 === void 0 ? void 0 : _input_layout_template_layout1.colorway, colorwayType, (_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.color, colorMap, isDarkTheme);
1110
- const validXYRanges = getValidXYRanges(series, resolveXValue);
1111
- validXYRanges.forEach(([rangeStart, rangeEnd], rangeIdx)=>{
1112
- const rangeXValues = series.x.slice(rangeStart, rangeEnd);
1113
- const rangeYValues = series.y.slice(rangeStart, rangeEnd);
1114
- const textValues = Array.isArray(series.text) ? series.text.slice(rangeStart, rangeEnd) : typeof series.text === 'string' ? series.text : undefined;
1115
- rangeXValues.forEach((x, index2)=>{
1116
- var _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout;
1117
- if (!mapXToDataPoints[x]) {
1118
- mapXToDataPoints[x] = {
1119
- xAxisPoint: resolveXValue(x),
1120
- chartData: [],
1121
- lineData: []
1122
- };
1123
- }
1124
- const legend = legends[index1];
1125
- // resolve color for each legend's bars from the colorscale or extracted colors
1126
- const color = colorScale ? colorScale(isArrayOrTypedArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) ? (_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[index2 % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : resolveColor(extractedBarColors, index2, legend, colorMap, (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, isDarkTheme);
1127
- const opacity = getOpacity(series, index2);
1128
- const yVal = rangeYValues[index2];
1129
- const yAxisCalloutData = getFormattedCalloutYData(yVal, yAxisTickFormat);
1130
- let barLabel = Array.isArray(textValues) ? textValues[index2] : textValues;
1131
- // Apply texttemplate formatting if specified
1132
- if (barLabel && series.texttemplate) {
1133
- barLabel = formatTextWithTemplate(barLabel, series.texttemplate, index2);
1134
- }
1135
- if (series.type === 'bar') {
1136
- var _rgb_copy_formatHex8;
1137
- mapXToDataPoints[x].chartData.push({
1138
- legend,
1139
- data: yVal,
1140
- color: (_rgb_copy_formatHex8 = rgb(color).copy({
1141
- opacity
1142
- }).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
1143
- yAxisCalloutData,
1144
- ...barLabel ? {
1145
- barLabel: String(barLabel)
1146
- } : {}
1147
- });
1148
- if (typeof yVal === 'number') {
1149
- yMaxValue = Math.max(yMaxValue, yVal);
1150
- }
1151
- } else if (series.type === 'scatter' || !!fallbackVSBC) {
1152
- var _input_layout_template_layout1, _input_layout_template1, _input_layout1, _series_mode;
1153
- const lineColor = resolveColor(extractedLineColors, index1, legend, colorMap, (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_template1 = _input_layout1.template) === null || _input_layout_template1 === void 0 ? void 0 : (_input_layout_template_layout1 = _input_layout_template1.layout) === null || _input_layout_template_layout1 === void 0 ? void 0 : _input_layout_template_layout1.colorway, isDarkTheme);
1154
- const lineOptions = !((_series_mode = series.mode) === null || _series_mode === void 0 ? void 0 : _series_mode.includes('text')) ? getLineOptions(series.line) : undefined;
1155
- const legendShape = getLegendShape(series);
1156
- var _rgb_copy_formatHex81;
1157
- mapXToDataPoints[x].lineData.push({
1158
- legend: legend + (validXYRanges.length > 1 ? `.${rangeIdx + 1}` : ''),
1159
- legendShape,
1160
- y: yVal,
1161
- color: (_rgb_copy_formatHex81 = rgb(lineColor).copy({
1162
- opacity
1163
- }).formatHex8()) !== null && _rgb_copy_formatHex81 !== void 0 ? _rgb_copy_formatHex81 : color,
1164
- lineOptions: {
1165
- ...lineOptions !== null && lineOptions !== void 0 ? lineOptions : {},
1166
- mode: series.mode
1167
- },
1168
- useSecondaryYScale: usesSecondaryYScale(series, input.layout),
1169
- yAxisCalloutData
1170
- });
1171
- if (!usesSecondaryYScale(series, input.layout) && typeof yVal === 'number') {
1172
- yMaxValue = Math.max(yMaxValue, yVal);
1173
- yMinValue = Math.min(yMinValue, yVal);
1174
- }
1175
- }
1176
- yMaxValue = Math.max(yMaxValue, yVal);
1177
- });
1178
- });
1179
- });
1180
- const xCategories = extractXCategories(input.data);
1181
- var _input_layout_shapes;
1182
- ((_input_layout_shapes = (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.shapes) !== null && _input_layout_shapes !== void 0 ? _input_layout_shapes : []).filter((shape)=>shape.type === 'line').forEach((shape, shapeIdx)=>{
1183
- var _shape_line;
1184
- const lineColor = (_shape_line = shape.line) === null || _shape_line === void 0 ? void 0 : _shape_line.color;
1185
- const resolveX = (val)=>{
1186
- if (shape.xref === 'x domain') {
1187
- if (val === 0) {
1188
- return xCategories[0];
1189
- }
1190
- if (val === 1) {
1191
- return xCategories[xCategories.length - 1];
1192
- }
1193
- }
1194
- if (typeof val === 'number' && Array.isArray(xCategories)) {
1195
- if (xCategories[val] !== undefined) {
1196
- return xCategories[val];
1197
- } else {
1198
- return xCategories[shapeIdx];
1199
- }
1200
- }
1201
- return val;
1202
- };
1203
- const x0Key = resolveX(shape.x0);
1204
- const x1Key = resolveX(shape.x1);
1205
- const resolveY = (val)=>{
1206
- if (shape.yref === 'paper') {
1207
- if (val === 0) {
1208
- return yMinValue;
1209
- }
1210
- if (val === 1) {
1211
- return yMaxValue;
1212
- }
1213
- if (typeof val === 'number') {
1214
- return yMinValue + val * (yMaxValue - yMinValue);
1215
- }
1216
- return val;
1217
- }
1218
- return val;
1219
- };
1220
- const y0Val = resolveY(shape.y0);
1221
- const y1Val = resolveY(shape.y1);
1222
- if (mapXToDataPoints[x0Key]) {
1223
- var _rgb_formatHex8;
1224
- mapXToDataPoints[x0Key].lineData.push({
1225
- legend: `Reference_${shapeIdx}`,
1226
- y: y0Val,
1227
- color: (_rgb_formatHex8 = rgb(lineColor).formatHex8()) !== null && _rgb_formatHex8 !== void 0 ? _rgb_formatHex8 : lineColor,
1228
- lineOptions: getLineOptions(shape.line),
1229
- useSecondaryYScale: false
1230
- });
1231
- }
1232
- if (mapXToDataPoints[x1Key]) {
1233
- var _rgb_formatHex81;
1234
- mapXToDataPoints[x1Key].lineData.push({
1235
- legend: `Reference_${shapeIdx}`,
1236
- y: y1Val,
1237
- color: (_rgb_formatHex81 = rgb(lineColor).formatHex8()) !== null && _rgb_formatHex81 !== void 0 ? _rgb_formatHex81 : lineColor,
1238
- lineOptions: getLineOptions(shape.line),
1239
- useSecondaryYScale: false
1240
- });
1241
- }
1242
- });
1243
- const vsbcData = Object.values(mapXToDataPoints);
1244
- const annotations = getChartAnnotationsFromLayout(input.data, input.layout, isMultiPlot);
1245
- var _input_layout_height;
1246
- return {
1247
- data: vsbcData,
1248
- width: (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.width,
1249
- height: (_input_layout_height = (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
1250
- barWidth: 'auto',
1251
- yMaxValue,
1252
- yMinValue,
1253
- mode: 'plotly',
1254
- ...secondaryYAxisValues,
1255
- hideTickOverlap: true,
1256
- barGapMax: 2,
1257
- hideLegend,
1258
- roundCorners: true,
1259
- showYAxisLables: true,
1260
- noOfCharsToTruncate: 20,
1261
- showYAxisLablesTooltip: true,
1262
- roundedTicks: true,
1263
- ...getXMinMaxValues(input.data[0], input.layout),
1264
- ...getTitles(input.layout),
1265
- ...getXAxisTickFormat(input.data[0], input.layout),
1266
- ...yAxisTickFormat,
1267
- ...getAxisCategoryOrderProps(input.data, input.layout),
1268
- ...getBarProps(input.data, input.layout),
1269
- ...getYMinMaxValues(input.data[0], input.layout),
1270
- ...getAxisTickProps(input.data, input.layout),
1271
- ...annotations ? {
1272
- annotations
1273
- } : {}
1274
- };
1275
- };
1276
- export const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
1277
- var _processedInput_layout, _processedInput_layout1;
1278
- // Handle object arrays in y values by normalizing the data first
1279
- let processedInput = {
1280
- ...input
1281
- };
1282
- // Check if any bar traces have object arrays as y values
1283
- const hasObjectArrayData = input.data.some((series)=>series.type === 'bar' && isObjectArray(series.y));
1284
- if (hasObjectArrayData) {
1285
- // Process each trace that has object array y values
1286
- const processedData = input.data.map((series, index)=>{
1287
- if (series.type === 'bar' && isObjectArray(series.y)) {
1288
- // Normalize the object array to create multiple traces for GVBC
1289
- const { traces } = normalizeObjectArrayForGVBC(series.y, Array.isArray(series.x) ? series.x : undefined);
1290
- // Return all the new traces, each representing a property from the objects
1291
- return traces.map((trace)=>({
1292
- ...trace,
1293
- // Copy other properties from the original series if needed
1294
- marker: series.marker
1295
- }));
1296
- }
1297
- return [
1298
- series
1299
- ];
1300
- }).flat();
1301
- processedInput = {
1302
- ...input,
1303
- data: processedData
1304
- };
1305
- }
1306
- const gvbcDataV2 = [];
1307
- const secondaryYAxisValues = getSecondaryYAxisValues(processedInput.data, processedInput.layout);
1308
- const { legends, hideLegend } = getLegendProps(processedInput.data, processedInput.layout, isMultiPlot);
1309
- let colorScale = undefined;
1310
- const yAxisTickFormat = getYAxisTickFormat(processedInput.data[0], processedInput.layout);
1311
- processedInput.data.forEach((series, index1)=>{
1312
- colorScale = createColorScale(processedInput.layout, series, colorScale);
1313
- const legend = legends[index1];
1314
- const legendShape = getLegendShape(series);
1315
- if (series.type === 'bar') {
1316
- var _processedInput_layout_template_layout, _processedInput_layout_template, _processedInput_layout, _series_marker;
1317
- // extract bar colors for each series only once
1318
- const extractedBarColors = extractColor((_processedInput_layout = processedInput.layout) === null || _processedInput_layout === void 0 ? void 0 : (_processedInput_layout_template = _processedInput_layout.template) === null || _processedInput_layout_template === void 0 ? void 0 : (_processedInput_layout_template_layout = _processedInput_layout_template.layout) === null || _processedInput_layout_template_layout === void 0 ? void 0 : _processedInput_layout_template_layout.colorway, colorwayType, (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color, colorMap, isDarkTheme);
1319
- gvbcDataV2.push({
1320
- type: 'bar',
1321
- legend,
1322
- key: legend,
1323
- data: series.x.map((x, xIndex)=>{
1324
- var _series_y, _series_marker, _series_marker1, _series_marker_color, _series_marker2, _processedInput_layout_template_layout, _processedInput_layout_template, _processedInput_layout;
1325
- if (isInvalidValue(x) || isInvalidValue((_series_y = series.y) === null || _series_y === void 0 ? void 0 : _series_y[xIndex])) {
1326
- return;
1327
- }
1328
- // resolve color for each legend's bars from the colorscale or extracted colors
1329
- const color = colorScale ? colorScale(isArrayOrTypedArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) ? (_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[xIndex % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : resolveColor(extractedBarColors, xIndex, legend, colorMap, (_processedInput_layout = processedInput.layout) === null || _processedInput_layout === void 0 ? void 0 : (_processedInput_layout_template = _processedInput_layout.template) === null || _processedInput_layout_template === void 0 ? void 0 : (_processedInput_layout_template_layout = _processedInput_layout_template.layout) === null || _processedInput_layout_template_layout === void 0 ? void 0 : _processedInput_layout_template_layout.colorway, isDarkTheme);
1330
- const opacity = getOpacity(series, xIndex);
1331
- const yVal = series.y[xIndex];
1332
- // Extract text value for barLabel
1333
- let barLabel = Array.isArray(series.text) ? series.text[xIndex] : series.text;
1334
- // Apply texttemplate formatting if specified
1335
- if (barLabel && series.texttemplate) {
1336
- barLabel = formatTextWithTemplate(barLabel, series.texttemplate, xIndex);
1337
- }
1338
- var _rgb_copy_formatHex8;
1339
- return {
1340
- x: x.toString(),
1341
- y: yVal,
1342
- yAxisCalloutData: getFormattedCalloutYData(yVal, yAxisTickFormat),
1343
- color: (_rgb_copy_formatHex8 = rgb(color).copy({
1344
- opacity
1345
- }).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
1346
- ...barLabel ? {
1347
- barLabel: String(barLabel)
1348
- } : {}
1349
- };
1350
- }).filter((item)=>typeof item !== 'undefined'),
1351
- useSecondaryYScale: usesSecondaryYScale(series, processedInput.layout)
1352
- });
1353
- } else if (series.type === 'scatter') {
1354
- var _processedInput_layout_template_layout1, _processedInput_layout_template1, _processedInput_layout1, _series_line, _processedInput_layout_template_layout2, _processedInput_layout_template2, _processedInput_layout2;
1355
- // extract line colors for each series only once
1356
- const extractedLineColors = extractColor((_processedInput_layout1 = processedInput.layout) === null || _processedInput_layout1 === void 0 ? void 0 : (_processedInput_layout_template1 = _processedInput_layout1.template) === null || _processedInput_layout_template1 === void 0 ? void 0 : (_processedInput_layout_template_layout1 = _processedInput_layout_template1.layout) === null || _processedInput_layout_template_layout1 === void 0 ? void 0 : _processedInput_layout_template_layout1.colorway, colorwayType, (_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.color, colorMap, isDarkTheme);
1357
- const lineColor = resolveColor(extractedLineColors, index1, legend, colorMap, (_processedInput_layout2 = processedInput.layout) === null || _processedInput_layout2 === void 0 ? void 0 : (_processedInput_layout_template2 = _processedInput_layout2.template) === null || _processedInput_layout_template2 === void 0 ? void 0 : (_processedInput_layout_template_layout2 = _processedInput_layout_template2.layout) === null || _processedInput_layout_template_layout2 === void 0 ? void 0 : _processedInput_layout_template_layout2.colorway, isDarkTheme);
1358
- const lineOptions = getLineOptions(series.line);
1359
- const opacity = getOpacity(series, index1);
1360
- const validXYRanges = getValidXYRanges(series);
1361
- validXYRanges.forEach(([rangeStart, rangeEnd])=>{
1362
- const rangeXValues = series.x.slice(rangeStart, rangeEnd);
1363
- const rangeYValues = series.y.slice(rangeStart, rangeEnd);
1364
- var _rgb_copy_formatHex8;
1365
- gvbcDataV2.push({
1366
- type: 'line',
1367
- legend,
1368
- legendShape,
1369
- data: rangeXValues.map((x, i)=>{
1370
- const yVal = rangeYValues[i];
1371
- return {
1372
- x: x.toString(),
1373
- y: yVal,
1374
- yAxisCalloutData: getFormattedCalloutYData(yVal, yAxisTickFormat)
1375
- };
1376
- }),
1377
- color: (_rgb_copy_formatHex8 = rgb(lineColor).copy({
1378
- opacity
1379
- }).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : lineColor,
1380
- lineOptions: {
1381
- ...lineOptions !== null && lineOptions !== void 0 ? lineOptions : {},
1382
- mode: series.mode
1383
- },
1384
- useSecondaryYScale: usesSecondaryYScale(series, processedInput.layout)
1385
- });
1386
- });
1387
- }
1388
- });
1389
- const annotations = getChartAnnotationsFromLayout(processedInput.data, processedInput.layout, isMultiPlot);
1390
- var _processedInput_layout_height;
1391
- return {
1392
- dataV2: gvbcDataV2,
1393
- width: (_processedInput_layout = processedInput.layout) === null || _processedInput_layout === void 0 ? void 0 : _processedInput_layout.width,
1394
- height: (_processedInput_layout_height = (_processedInput_layout1 = processedInput.layout) === null || _processedInput_layout1 === void 0 ? void 0 : _processedInput_layout1.height) !== null && _processedInput_layout_height !== void 0 ? _processedInput_layout_height : 350,
1395
- barWidth: 'auto',
1396
- mode: 'plotly',
1397
- ...secondaryYAxisValues,
1398
- hideTickOverlap: true,
1399
- hideLegend,
1400
- roundCorners: true,
1401
- showYAxisLables: true,
1402
- roundedTicks: true,
1403
- ...getXMinMaxValues(processedInput.data[0], processedInput.layout),
1404
- ...getTitles(processedInput.layout),
1405
- ...getAxisCategoryOrderProps(processedInput.data, processedInput.layout),
1406
- ...getYMinMaxValues(processedInput.data[0], processedInput.layout),
1407
- ...getXAxisTickFormat(processedInput.data[0], processedInput.layout),
1408
- ...yAxisTickFormat,
1409
- ...getBarProps(processedInput.data, processedInput.layout),
1410
- ...getAxisTickProps(processedInput.data, processedInput.layout),
1411
- ...annotations ? {
1412
- annotations
1413
- } : {}
1414
- };
1415
- };
1416
- export const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
1417
- var _input_layout, _input_layout1;
1418
- const vbcData = [];
1419
- const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
1420
- let colorScale = undefined;
1421
- input.data.forEach((series, seriesIdx)=>{
1422
- var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _series_xbins, _series_xbins1, _series_xbins2;
1423
- if (!series.x) {
1424
- return;
1425
- }
1426
- colorScale = createColorScale(input.layout, series, colorScale);
1427
- // extract colors for each series only once
1428
- const extractedColors = extractColor((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color, colorMap, isDarkTheme);
1429
- const xValues = [];
1430
- const yValues = [];
1431
- series.x.forEach((xVal, index)=>{
1432
- var _getNumberAtIndexOrDefault;
1433
- const yVal = (_getNumberAtIndexOrDefault = getNumberAtIndexOrDefault(series.y, index)) !== null && _getNumberAtIndexOrDefault !== void 0 ? _getNumberAtIndexOrDefault : 0;
1434
- if (isInvalidValue(xVal)) {
1435
- return;
1436
- }
1437
- xValues.push(xVal);
1438
- yValues.push(yVal);
1439
- });
1440
- const isXString = isStringArray(xValues);
1441
- // TODO: In case of a single bin, add an empty bin of the same size to prevent the
1442
- // default bar width from being used and ensure the bar spans the full intended range.
1443
- const xBins = createBins(xValues, (_series_xbins = series.xbins) === null || _series_xbins === void 0 ? void 0 : _series_xbins.start, (_series_xbins1 = series.xbins) === null || _series_xbins1 === void 0 ? void 0 : _series_xbins1.end, (_series_xbins2 = series.xbins) === null || _series_xbins2 === void 0 ? void 0 : _series_xbins2.size);
1444
- const yBins = xBins.map(()=>[]);
1445
- let total = 0;
1446
- xValues.forEach((xVal, index)=>{
1447
- const binIdx = findBinIndex(xBins, xVal, isXString);
1448
- if (binIdx !== -1) {
1449
- yBins[binIdx].push(yValues[index]);
1450
- }
1451
- });
1452
- const y = yBins.map((bin)=>{
1453
- const yVal = calculateHistFunc(series.histfunc, bin);
1454
- total += yVal;
1455
- return yVal;
1456
- });
1457
- xBins.forEach((bin, index)=>{
1458
- var _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout;
1459
- const legend = legends[seriesIdx];
1460
- // resolve color for each legend's bars from the colorscale or extracted colors
1461
- const color = colorScale ? colorScale(isArrayOrTypedArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) ? (_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[index % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : resolveColor(extractedColors, index, legend, colorMap, (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, isDarkTheme);
1462
- const opacity = getOpacity(series, index);
1463
- const yVal = calculateHistNorm(series.histnorm, y[index], total, isXString ? bin.length : getBinSize(bin));
1464
- // Handle text values and texttemplate formatting for histogram bins
1465
- let barLabel = Array.isArray(series.text) ? series.text[index] : series.text;
1466
- if (barLabel && series.texttemplate) {
1467
- barLabel = formatTextWithTemplate(barLabel, series.texttemplate, index);
1468
- }
1469
- var _rgb_copy_formatHex8;
1470
- vbcData.push({
1471
- x: isXString ? bin.join(', ') : getBinCenter(bin),
1472
- y: yVal,
1473
- legend,
1474
- color: (_rgb_copy_formatHex8 = rgb(color).copy({
1475
- opacity
1476
- }).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
1477
- ...isXString ? {} : {
1478
- xAxisCalloutData: `[${bin.x0} - ${bin.x1})`
1479
- },
1480
- ...barLabel ? {
1481
- barLabel: String(barLabel)
1482
- } : {}
1483
- });
1484
- });
1485
- });
1486
- const annotations = getChartAnnotationsFromLayout(input.data, input.layout, isMultiPlot);
1487
- var _input_layout_height;
1488
- return {
1489
- data: vbcData,
1490
- width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
1491
- height: (_input_layout_height = (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
1492
- mode: 'histogram',
1493
- hideTickOverlap: true,
1494
- maxBarWidth: 50,
1495
- hideLegend,
1496
- roundCorners: true,
1497
- showYAxisLables: true,
1498
- roundedTicks: true,
1499
- ...getXMinMaxValues(input.data[0], input.layout),
1500
- ...getTitles(input.layout),
1501
- ...getYMinMaxValues(input.data[0], input.layout),
1502
- ...getAxisCategoryOrderProps(input.data, input.layout),
1503
- ...annotations ? {
1504
- annotations
1505
- } : {}
1506
- };
1507
- };
1508
- export const transformPlotlyJsonToAreaChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
1509
- return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'area', colorMap, colorwayType, isDarkTheme);
1510
- };
1511
- export const transformPlotlyJsonToLineChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
1512
- return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'line', colorMap, colorwayType, isDarkTheme);
1513
- };
1514
- export const transformPlotlyJsonToScatterChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
1515
- return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'scatter', colorMap, colorwayType, isDarkTheme);
1516
- };
1517
- const mapColorFillBars = (layout)=>{
1518
- if (!Array.isArray(layout === null || layout === void 0 ? void 0 : layout.shapes)) {
1519
- return [];
1520
- }
1521
- return layout.shapes.filter((shape)=>shape.type === 'rect').map((shape)=>{
1522
- //colorFillbars doesn't support string dates or categories
1523
- if (typeof shape.x0 === 'string' || typeof shape.x1 === 'string') {
1524
- return null;
1525
- }
1526
- return {
1527
- color: shape.fillcolor,
1528
- data: [
1529
- {
1530
- startX: shape.x0,
1531
- endX: shape.x1
1532
- }
1533
- ],
1534
- applyPattern: false
1535
- };
1536
- });
1537
- };
1538
- const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme)=>{
1539
- var _input_data_, _chartData__data_, _chartData_, _chartData__data_1, _chartData_1, _chartData__data_2, _chartData_2, _chartData__data_3, _chartData_3, _input_layout, _input_layout1, _input_layout2;
1540
- const isScatterMarkers = [
1541
- 'text',
1542
- 'markers',
1543
- 'text+markers',
1544
- 'markers+text',
1545
- 'lines+markers',
1546
- 'markers+line',
1547
- 'text+lines+markers',
1548
- 'lines+markers+text'
1549
- ].includes((_input_data_ = input.data[0]) === null || _input_data_ === void 0 ? void 0 : _input_data_.mode);
1550
- const isAreaChart = chartType === 'area';
1551
- const isScatterChart = chartType === 'scatter';
1552
- const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
1553
- let mode = 'tonexty';
1554
- const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
1555
- const yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
1556
- const resolveXValue = getAxisValueResolver(getAxisType(input.data, getAxisObjects(input.data, input.layout).x));
1557
- const chartData = input.data.map((series, index)=>{
1558
- var _series_mode, _series_line, _series_marker, _series_line1, _input_layout_template_layout, _input_layout_template, _input_layout, _input_layout_template_layout1, _input_layout_template1, _input_layout1, _series_mode1;
1559
- const colors = isScatterMarkers ? (series === null || series === void 0 ? void 0 : (_series_mode = series.mode) === null || _series_mode === void 0 ? void 0 : _series_mode.includes('line')) ? (_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.color : (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color : (_series_line1 = series.line) === null || _series_line1 === void 0 ? void 0 : _series_line1.color;
1560
- // extract colors for each series only once
1561
- const extractedColors = extractColor((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, colors, colorMap, isDarkTheme);
1562
- const xValues = series.x;
1563
- const legend = legends[index];
1564
- // resolve color for each legend's lines from the extracted colors
1565
- const seriesColor = resolveColor(extractedColors, index, legend, colorMap, (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_template1 = _input_layout1.template) === null || _input_layout_template1 === void 0 ? void 0 : (_input_layout_template_layout1 = _input_layout_template1.layout) === null || _input_layout_template_layout1 === void 0 ? void 0 : _input_layout_template_layout1.colorway, isDarkTheme);
1566
- const seriesOpacity = getOpacity(series, index);
1567
- mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
1568
- // if mode contains 'text', we prioritize showing the text over curving the line
1569
- const lineOptions = !((_series_mode1 = series.mode) === null || _series_mode1 === void 0 ? void 0 : _series_mode1.includes('text')) && series.type !== 'scatterpolar' ? getLineOptions(series.line) : undefined;
1570
- const legendShape = getLegendShape(series);
1571
- const validXYRanges = getValidXYRanges(series, resolveXValue);
1572
- return validXYRanges.map(([rangeStart, rangeEnd], rangeIdx)=>{
1573
- var _series_marker, _series_marker1, _series_marker2, _input_layout, _input_layout_polar_angularaxis, _input_layout_polar, _input_layout1, _input_layout_polar_angularaxis1, _input_layout_polar1, _input_layout2;
1574
- const rangeXValues = xValues.slice(rangeStart, rangeEnd);
1575
- const rangeYValues = series.y.slice(rangeStart, rangeEnd);
1576
- const markerSizes = isArrayOrTypedArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.size) ? series.marker.size.slice(rangeStart, rangeEnd) : [];
1577
- const markerColors = isArrayOrTypedArray((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color) ? series.marker.color.slice(rangeStart, rangeEnd) : Array.isArray((_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : _series_marker2.color) ? series.marker.color.slice(rangeStart, rangeEnd) : undefined;
1578
- const textValues = Array.isArray(series.text) ? series.text.slice(rangeStart, rangeEnd) : undefined;
1579
- var _rgb_copy_formatHex8;
1580
- return {
1581
- legend,
1582
- legendShape,
1583
- data: rangeXValues.map((x, i)=>{
1584
- var _series_marker, _series_marker1;
1585
- return {
1586
- x: resolveXValue(x),
1587
- y: rangeYValues[i],
1588
- ...Array.isArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.size) ? {
1589
- markerSize: markerSizes[i]
1590
- } : typeof ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.size) === 'number' ? {
1591
- markerSize: series.marker.size
1592
- } : {},
1593
- ...markerColors ? {
1594
- markerColor: markerColors[i]
1595
- } : {},
1596
- ...textValues ? {
1597
- text: textValues[i]
1598
- } : {},
1599
- yAxisCalloutData: getFormattedCalloutYData(rangeYValues[i], yAxisTickFormat)
1600
- };
1601
- }),
1602
- color: (_rgb_copy_formatHex8 = rgb(seriesColor).copy({
1603
- opacity: seriesOpacity
1604
- }).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : seriesColor,
1605
- lineOptions: {
1606
- ...lineOptions !== null && lineOptions !== void 0 ? lineOptions : {},
1607
- mode: series.type !== 'scatterpolar' ? series.mode : 'scatterpolar',
1608
- // originXOffset is not typed on Layout, but may be present in input.layout as a part of projection of
1609
- // scatter polar coordingates to cartesian coordinates
1610
- ...series.type === 'scatterpolar' ? {
1611
- originXOffset: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.__polarOriginX,
1612
- direction: (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_polar = _input_layout1.polar) === null || _input_layout_polar === void 0 ? void 0 : (_input_layout_polar_angularaxis = _input_layout_polar.angularaxis) === null || _input_layout_polar_angularaxis === void 0 ? void 0 : _input_layout_polar_angularaxis.direction,
1613
- rotation: (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : (_input_layout_polar1 = _input_layout2.polar) === null || _input_layout_polar1 === void 0 ? void 0 : (_input_layout_polar_angularaxis1 = _input_layout_polar1.angularaxis) === null || _input_layout_polar_angularaxis1 === void 0 ? void 0 : _input_layout_polar_angularaxis1.rotation,
1614
- axisLabel: series.__axisLabel ? series.__axisLabel : {},
1615
- fill: series.fill
1616
- } : {}
1617
- },
1618
- useSecondaryYScale: usesSecondaryYScale(series, input.layout)
1619
- };
1620
- });
1621
- }).flat();
1622
- const xMinValue = (_chartData_ = chartData[0]) === null || _chartData_ === void 0 ? void 0 : (_chartData__data_ = _chartData_.data[0]) === null || _chartData__data_ === void 0 ? void 0 : _chartData__data_.x;
1623
- const xMaxValue = (_chartData_1 = chartData[0]) === null || _chartData_1 === void 0 ? void 0 : (_chartData__data_1 = _chartData_1.data[chartData[0].data.length - 1]) === null || _chartData__data_1 === void 0 ? void 0 : _chartData__data_1.x;
1624
- const yMinValue = (_chartData_2 = chartData[0]) === null || _chartData_2 === void 0 ? void 0 : (_chartData__data_2 = _chartData_2.data[0]) === null || _chartData__data_2 === void 0 ? void 0 : _chartData__data_2.y;
1625
- const yMaxValue = (_chartData_3 = chartData[0]) === null || _chartData_3 === void 0 ? void 0 : (_chartData__data_3 = _chartData_3.data[chartData[0].data.length - 1]) === null || _chartData__data_3 === void 0 ? void 0 : _chartData__data_3.y;
1626
- const xCategories = extractXCategories(input.data);
1627
- var _input_layout_shapes;
1628
- const lineShape = ((_input_layout_shapes = (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.shapes) !== null && _input_layout_shapes !== void 0 ? _input_layout_shapes : []).filter((shape)=>shape.type === 'line').map((shape, shapeIdx)=>{
1629
- var _shape_line;
1630
- const lineColor = (_shape_line = shape.line) === null || _shape_line === void 0 ? void 0 : _shape_line.color;
1631
- const resolveX = (val)=>{
1632
- if (typeof val === 'number' && Array.isArray(xCategories)) {
1633
- if (xCategories[val] !== undefined) {
1634
- return xCategories[val];
1635
- } else {
1636
- return xCategories[shapeIdx];
1637
- }
1638
- }
1639
- if (shape.xref === 'paper') {
1640
- if (val === 0) {
1641
- return xMinValue;
1642
- }
1643
- if (val === 1) {
1644
- return xMaxValue;
1645
- }
1646
- if (typeof val === 'number' && typeof xMinValue === 'number' && typeof xMaxValue === 'number') {
1647
- return xMinValue + val * (xMaxValue - xMinValue);
1648
- }
1649
- return val;
1650
- }
1651
- return val;
1652
- };
1653
- const resolveY = (val)=>{
1654
- if (shape.yref === 'paper') {
1655
- if (val === 0) {
1656
- return yMinValue;
1657
- }
1658
- if (val === 1) {
1659
- return yMaxValue;
1660
- }
1661
- if (typeof val === 'number') {
1662
- return yMinValue + val * (yMaxValue - yMinValue);
1663
- }
1664
- return val;
1665
- }
1666
- return val;
1667
- };
1668
- var _rgb_formatHex8;
1669
- return {
1670
- legend: `Reference_${shapeIdx}`,
1671
- data: [
1672
- {
1673
- x: resolveXValue(resolveX(shape.x0)),
1674
- y: resolveY(shape.y0)
1675
- },
1676
- {
1677
- x: resolveXValue(resolveX(shape.x1)),
1678
- y: resolveY(shape.y1)
1679
- }
1680
- ],
1681
- color: (_rgb_formatHex8 = rgb(lineColor).formatHex8()) !== null && _rgb_formatHex8 !== void 0 ? _rgb_formatHex8 : lineColor,
1682
- lineOptions: getLineOptions(shape.line),
1683
- useSecondaryYScale: false
1684
- };
1685
- });
1686
- const yMinMax = getYMinMaxValues(input.data[0], input.layout);
1687
- if (yMinMax.yMinValue === undefined && yMinMax.yMaxValue === undefined) {
1688
- const yMinMaxValues = findNumericMinMaxOfY(chartData);
1689
- yMinMax.yMinValue = yMinMaxValues.startValue;
1690
- yMinMax.yMaxValue = yMinMaxValues.endValue;
1691
- }
1692
- const numDataPoints = chartData.reduce((total, lineChartPoints)=>total + lineChartPoints.data.length, 0);
1693
- const chartProps = {
1694
- lineChartData: [
1695
- ...chartData,
1696
- ...lineShape
1697
- ]
1698
- };
1699
- const scatterChartProps = {
1700
- scatterChartData: [
1701
- ...chartData,
1702
- ...lineShape
1703
- ]
1704
- };
1705
- const annotations = getChartAnnotationsFromLayout(input.data, input.layout, isMultiPlot);
1706
- var _input_layout_height;
1707
- const commonProps = {
1708
- supportNegativeData: true,
1709
- ...secondaryYAxisValues,
1710
- width: (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.width,
1711
- height: (_input_layout_height = (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
1712
- hideTickOverlap: true,
1713
- hideLegend,
1714
- useUTC: false,
1715
- optimizeLargeData: numDataPoints > 1000,
1716
- showYAxisLables: true,
1717
- roundedTicks: true,
1718
- ...getXMinMaxValues(input.data[0], input.layout),
1719
- ...getTitles(input.layout),
1720
- ...getXAxisTickFormat(input.data[0], input.layout),
1721
- ...yAxisTickFormat,
1722
- ...getAxisScaleTypeProps(input.data, input.layout),
1723
- ...getAxisTickProps(input.data, input.layout),
1724
- ...annotations ? {
1725
- annotations
1726
- } : {}
1727
- };
1728
- if (isAreaChart) {
1729
- return {
1730
- data: chartProps,
1731
- mode,
1732
- ...commonProps
1733
- };
1734
- } else {
1735
- return {
1736
- data: isScatterChart ? scatterChartProps : chartProps,
1737
- ...commonProps,
1738
- ...yMinMax,
1739
- ...isScatterChart ? {
1740
- showYAxisLablesTooltip: true,
1741
- ...getAxisCategoryOrderProps(input.data, input.layout)
1742
- } : {},
1743
- ...!isScatterChart && (()=>{
1744
- const bars = mapColorFillBars(input.layout);
1745
- return bars && !bars.includes(null) ? {
1746
- colorFillBars: bars
1747
- } : {};
1748
- })()
1749
- };
1750
- }
1751
- };
1752
- export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
1753
- var _input_layout, _input_layout_margin, _input_layout1, _input_layout_margin1, _input_layout2, _input_layout_yaxis2, _input_layout3, _input_layout_yaxis21, _input_layout4, _input_layout_yaxis2_title, _input_layout_yaxis22, _input_layout5, _input_layout6;
1754
- const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
1755
- let colorScale = undefined;
1756
- const chartData = input.data.map((series, index)=>{
1757
- var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker;
1758
- colorScale = createColorScale(input.layout, series, colorScale);
1759
- // extract colors for each series only once
1760
- const extractedColors = extractColor((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color, colorMap, isDarkTheme);
1761
- const legend = legends[index];
1762
- return series.y.map((yValue, i)=>{
1763
- var _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout, _series_x, _series_text;
1764
- if (isInvalidValue(yValue)) {
1765
- return null;
1766
- }
1767
- // resolve color for each legend's bars from the colorscale or extracted colors
1768
- const color = colorScale ? colorScale(isArrayOrTypedArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) ? (_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[i % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : resolveColor(extractedColors, i, legend, colorMap, (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, isDarkTheme);
1769
- const opacity = getOpacity(series, i);
1770
- var _rgb_copy_formatHex8;
1771
- return {
1772
- x: isInvalidValue((_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x[i]) ? 0 : series.x[i],
1773
- y: yValue,
1774
- legend,
1775
- color: (_rgb_copy_formatHex8 = rgb(color).copy({
1776
- opacity
1777
- }).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
1778
- ...((_series_text = series.text) === null || _series_text === void 0 ? void 0 : _series_text[i]) ? {
1779
- barLabel: series.text[i].toString()
1780
- } : {}
1781
- };
1782
- }).filter((point)=>point !== null);
1783
- }).flat();
1784
- var _input_layout_height;
1785
- const chartHeight = (_input_layout_height = (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 450;
1786
- var _input_layout_margin_l;
1787
- const margin = (_input_layout_margin_l = (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_margin = _input_layout1.margin) === null || _input_layout_margin === void 0 ? void 0 : _input_layout_margin.l) !== null && _input_layout_margin_l !== void 0 ? _input_layout_margin_l : 0;
1788
- var _input_layout_margin_pad;
1789
- const padding = (_input_layout_margin_pad = (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : (_input_layout_margin1 = _input_layout2.margin) === null || _input_layout_margin1 === void 0 ? void 0 : _input_layout_margin1.pad) !== null && _input_layout_margin_pad !== void 0 ? _input_layout_margin_pad : 0;
1790
- const availableHeight = chartHeight - margin - padding;
1791
- const numberOfRows = new Set(chartData.map((d)=>d.y)).size || 1;
1792
- const scalingFactor = 0.01;
1793
- const gapFactor = 1 / (1 + scalingFactor * numberOfRows);
1794
- const barHeight = availableHeight / (numberOfRows * (1 + gapFactor));
1795
- return {
1796
- data: chartData,
1797
- secondaryYAxistitle: typeof ((_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : (_input_layout_yaxis2 = _input_layout3.yaxis2) === null || _input_layout_yaxis2 === void 0 ? void 0 : _input_layout_yaxis2.title) === 'string' ? (_input_layout4 = input.layout) === null || _input_layout4 === void 0 ? void 0 : (_input_layout_yaxis21 = _input_layout4.yaxis2) === null || _input_layout_yaxis21 === void 0 ? void 0 : _input_layout_yaxis21.title : ((_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : (_input_layout_yaxis22 = _input_layout5.yaxis2) === null || _input_layout_yaxis22 === void 0 ? void 0 : (_input_layout_yaxis2_title = _input_layout_yaxis22.title) === null || _input_layout_yaxis2_title === void 0 ? void 0 : _input_layout_yaxis2_title.text) || '',
1798
- barHeight,
1799
- showYAxisLables: true,
1800
- height: chartHeight,
1801
- width: (_input_layout6 = input.layout) === null || _input_layout6 === void 0 ? void 0 : _input_layout6.width,
1802
- hideTickOverlap: true,
1803
- noOfCharsToTruncate: 20,
1804
- showYAxisLablesTooltip: true,
1805
- hideLegend,
1806
- roundCorners: true,
1807
- roundedTicks: true,
1808
- ...getXMinMaxValues(input.data[0], input.layout),
1809
- ...getTitles(input.layout),
1810
- ...getAxisCategoryOrderProps(input.data, input.layout),
1811
- ...getBarProps(input.data, input.layout, true),
1812
- ...getAxisTickProps(input.data, input.layout)
1813
- };
1814
- };
1815
- export const transformPlotlyJsonToGanttChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
1816
- var _input_layout, _input_layout1;
1817
- const data = input.data.filter((series)=>series.type !== 'scatter' || series.mode !== 'markers');
1818
- const { legends, hideLegend } = getLegendProps(data, input.layout, isMultiPlot);
1819
- let colorScale = undefined;
1820
- const xAxisType = getAxisType(data, getAxisObjects(data, input.layout).x);
1821
- const resolveXValue = getAxisValueResolver(xAxisType, parseLocalDate);
1822
- const resolveGanttXValue = (value)=>{
1823
- const resolvedValue = resolveXValue(value);
1824
- return typeof resolvedValue === 'string' ? 0 : resolvedValue !== null && resolvedValue !== void 0 ? resolvedValue : 0;
1825
- };
1826
- const isXDate = xAxisType === 'date';
1827
- const ganttData = [];
1828
- data.forEach((series, index)=>{
1829
- const legend = legends[index];
1830
- if (series.type === 'bar') {
1831
- var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker;
1832
- colorScale = createColorScale(input.layout, series, colorScale);
1833
- // extract colors for each series only once
1834
- const extractedColors = extractColor((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color, colorMap, isDarkTheme);
1835
- series.y.forEach((yVal, i)=>{
1836
- var _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout, _series_x;
1837
- if (isInvalidValue(yVal)) {
1838
- return;
1839
- }
1840
- // resolve color for each legend's bars from the colorscale or extracted colors
1841
- const color = colorScale ? colorScale(isArrayOrTypedArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) ? (_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[i % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : resolveColor(extractedColors, i, legend, colorMap, (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, isDarkTheme);
1842
- const opacity = getOpacity(series, i);
1843
- const base = +resolveGanttXValue(isArrayOrTypedArray(series.base) ? series.base[i] : series.base);
1844
- const xVal = +resolveGanttXValue((_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x[i]);
1845
- var _rgb_copy_formatHex8;
1846
- ganttData.push({
1847
- x: {
1848
- start: isXDate ? new Date(base) : base,
1849
- end: isXDate ? new Date(base + xVal) : base + xVal
1850
- },
1851
- y: yVal,
1852
- legend,
1853
- color: (_rgb_copy_formatHex8 = rgb(color).copy({
1854
- opacity
1855
- }).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
1856
- });
1857
- });
1858
- } else if (series.type === 'scatter' && series.mode === 'none' && series.fill === 'toself') {
1859
- for(let i = 0; i < series.y.length; i += 5){
1860
- if (isInvalidValue(series.y[i]) || isInvalidValue(series.y[i + 3])) {
1861
- continue;
1862
- }
1863
- const x0 = resolveGanttXValue(series.x[i]);
1864
- const x1 = resolveGanttXValue(series.x[i + 1]);
1865
- const y0 = series.y[i];
1866
- const y1 = series.y[i + 3];
1867
- ganttData.push({
1868
- x: {
1869
- start: x0,
1870
- end: x1
1871
- },
1872
- y: Math.round((y0 + y1) / 2),
1873
- legend,
1874
- color: series.fillcolor
1875
- });
1876
- }
1877
- }
1878
- });
1879
- var _input_layout_height;
1880
- return {
1881
- data: ganttData,
1882
- showYAxisLables: true,
1883
- height: (_input_layout_height = (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
1884
- width: (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.width,
1885
- hideTickOverlap: true,
1886
- hideLegend,
1887
- noOfCharsToTruncate: 20,
1888
- showYAxisLablesTooltip: true,
1889
- roundCorners: true,
1890
- useUTC: false,
1891
- ...getTitles(input.layout),
1892
- ...getAxisCategoryOrderProps(data, input.layout),
1893
- ...getBarProps(data, input.layout, true),
1894
- ...getAxisTickProps(data, input.layout)
1895
- };
1896
- };
1897
- export const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
1898
- var _input_layout, _input_layout1, _input_layout_coloraxis, _input_layout2, _input_layout_template_layout, _input_layout_template, _input_layout3, _input_layout_template_data_histogram2d_, _input_layout_template_data_histogram2d, _input_layout_template_data, _input_layout_template1, _input_layout4, _input_layout_template_data_heatmap_, _input_layout_template_data_heatmap, _input_layout_template_data1, _input_layout_template2, _input_layout5, _input_layout6, _input_layout7;
1899
- const firstData = input.data[0];
1900
- const heatmapDataPoints = [];
1901
- let zMin = Number.POSITIVE_INFINITY;
1902
- let zMax = Number.NEGATIVE_INFINITY;
1903
- // Build a 2D array of annotations based on their grid position
1904
- const annotationGrid = [];
1905
- const rawAnnotations = (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.annotations;
1906
- if (rawAnnotations) {
1907
- const annotationsArray = Array.isArray(rawAnnotations) ? rawAnnotations : [
1908
- rawAnnotations
1909
- ];
1910
- // Collect all unique x and y values from valid annotations
1911
- const xSet = new Set();
1912
- const ySet = new Set();
1913
- const validAnnotations = [];
1914
- annotationsArray.forEach((a)=>{
1915
- if (a && typeof a.x === 'number' && typeof a.y === 'number' && typeof a.text === 'string' && (a.xref === 'x' || a.xref === undefined) && (a.yref === 'y' || a.yref === undefined)) {
1916
- xSet.add(a.x);
1917
- ySet.add(a.y);
1918
- validAnnotations.push({
1919
- x: a.x,
1920
- y: a.y,
1921
- text: cleanText(a.text)
1922
- });
1923
- }
1924
- });
1925
- if (validAnnotations.length > 0) {
1926
- // Get sorted unique x and y values
1927
- const xValues = Array.from(xSet).sort((a, b)=>a - b);
1928
- const yValues = Array.from(ySet).sort((a, b)=>a - b);
1929
- // Initialize 2D grid and populate
1930
- validAnnotations.forEach((annotation)=>{
1931
- const xIdx = xValues.indexOf(annotation.x);
1932
- const yIdx = yValues.indexOf(annotation.y);
1933
- if (!annotationGrid[yIdx]) {
1934
- annotationGrid[yIdx] = [];
1935
- }
1936
- annotationGrid[yIdx][xIdx] = annotation.text;
1937
- });
1938
- }
1939
- }
1940
- // Helper function to get annotation from 2D grid by index
1941
- const getAnnotationByIndex = (xIdx, yIdx)=>{
1942
- var _annotationGrid_yIdx;
1943
- return (_annotationGrid_yIdx = annotationGrid[yIdx]) === null || _annotationGrid_yIdx === void 0 ? void 0 : _annotationGrid_yIdx[xIdx];
1944
- };
1945
- if (firstData.type === 'histogram2d') {
1946
- var _firstData_x, _firstData_xbins, _firstData_xbins1, _firstData_xbins2, _firstData_ybins, _firstData_ybins1, _firstData_ybins2;
1947
- const xValues = [];
1948
- const yValues = [];
1949
- const zValues = [];
1950
- (_firstData_x = firstData.x) === null || _firstData_x === void 0 ? void 0 : _firstData_x.forEach((xVal, index)=>{
1951
- var _firstData_y;
1952
- var _getNumberAtIndexOrDefault;
1953
- const zVal = (_getNumberAtIndexOrDefault = getNumberAtIndexOrDefault(firstData.z, index)) !== null && _getNumberAtIndexOrDefault !== void 0 ? _getNumberAtIndexOrDefault : 0;
1954
- if (isInvalidValue(xVal) || isInvalidValue((_firstData_y = firstData.y) === null || _firstData_y === void 0 ? void 0 : _firstData_y[index])) {
1955
- return;
1956
- }
1957
- xValues.push(xVal);
1958
- yValues.push(firstData.y[index]);
1959
- zValues.push(zVal);
1960
- });
1961
- const isXString = isStringArray(xValues);
1962
- const isYString = isStringArray(yValues);
1963
- const xBins = createBins(xValues, (_firstData_xbins = firstData.xbins) === null || _firstData_xbins === void 0 ? void 0 : _firstData_xbins.start, (_firstData_xbins1 = firstData.xbins) === null || _firstData_xbins1 === void 0 ? void 0 : _firstData_xbins1.end, (_firstData_xbins2 = firstData.xbins) === null || _firstData_xbins2 === void 0 ? void 0 : _firstData_xbins2.size);
1964
- const yBins = createBins(yValues, (_firstData_ybins = firstData.ybins) === null || _firstData_ybins === void 0 ? void 0 : _firstData_ybins.start, (_firstData_ybins1 = firstData.ybins) === null || _firstData_ybins1 === void 0 ? void 0 : _firstData_ybins1.end, (_firstData_ybins2 = firstData.ybins) === null || _firstData_ybins2 === void 0 ? void 0 : _firstData_ybins2.size);
1965
- const zBins = yBins.map(()=>xBins.map(()=>[]));
1966
- let total = 0;
1967
- xValues.forEach((xVal, index)=>{
1968
- const xBinIdx = findBinIndex(xBins, xVal, isXString);
1969
- const yBinIdx = findBinIndex(yBins, yValues[index], isYString);
1970
- if (xBinIdx !== -1 && yBinIdx !== -1) {
1971
- zBins[yBinIdx][xBinIdx].push(zValues[index]);
1972
- }
1973
- });
1974
- const z = zBins.map((row)=>{
1975
- return row.map((bin)=>{
1976
- const zVal = calculateHistFunc(firstData.histfunc, bin);
1977
- total += zVal;
1978
- return zVal;
1979
- });
1980
- });
1981
- xBins.forEach((xBin, xIdx)=>{
1982
- yBins.forEach((yBin, yIdx)=>{
1983
- const zVal = calculateHistNorm(firstData.histnorm, z[yIdx][xIdx], total, isXString ? xBin.length : getBinSize(xBin), isYString ? yBin.length : getBinSize(yBin));
1984
- const annotationText = getAnnotationByIndex(xIdx, yIdx);
1985
- heatmapDataPoints.push({
1986
- x: isXString ? xBin.join(', ') : getBinCenter(xBin),
1987
- y: isYString ? yBin.join(', ') : getBinCenter(yBin),
1988
- value: zVal,
1989
- rectText: annotationText || zVal
1990
- });
1991
- if (typeof zVal === 'number') {
1992
- zMin = Math.min(zMin, zVal);
1993
- zMax = Math.max(zMax, zVal);
1994
- }
1995
- });
1996
- });
1997
- } else {
1998
- var _zArray_;
1999
- // If x and y are not provided, generate indices based on z dimensions
2000
- const zArray = firstData.z;
2001
- const xValues = firstData.x;
2002
- const yValues = firstData.y;
2003
- var _zArray_length;
2004
- // Determine the dimensions from z array
2005
- const yLength = (_zArray_length = zArray === null || zArray === void 0 ? void 0 : zArray.length) !== null && _zArray_length !== void 0 ? _zArray_length : 0;
2006
- var _zArray__length;
2007
- const xLength = (_zArray__length = zArray === null || zArray === void 0 ? void 0 : (_zArray_ = zArray[0]) === null || _zArray_ === void 0 ? void 0 : _zArray_.length) !== null && _zArray__length !== void 0 ? _zArray__length : 0;
2008
- // Use provided x/y values or generate indices
2009
- const xData = xValues !== null && xValues !== void 0 ? xValues : Array.from({
2010
- length: xLength
2011
- }, (_, i)=>i);
2012
- const yData = yValues !== null && yValues !== void 0 ? yValues : Array.from({
2013
- length: yLength
2014
- }, (_, i)=>yLength - 1 - i);
2015
- xData.forEach((xVal, xIdx)=>{
2016
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2017
- yData.forEach((yVal, yIdx)=>{
2018
- var _zArray_yIdx, _input_layout_xaxis, _input_layout, _input_layout_yaxis, _input_layout1;
2019
- const zVal = zArray === null || zArray === void 0 ? void 0 : (_zArray_yIdx = zArray[yIdx]) === null || _zArray_yIdx === void 0 ? void 0 : _zArray_yIdx[xIdx];
2020
- const annotationText = getAnnotationByIndex(xIdx, yIdx);
2021
- heatmapDataPoints.push({
2022
- x: ((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_xaxis = _input_layout.xaxis) === null || _input_layout_xaxis === void 0 ? void 0 : _input_layout_xaxis.type) === 'date' ? xVal : xVal !== null && xVal !== void 0 ? xVal : 0,
2023
- y: ((_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_yaxis = _input_layout1.yaxis) === null || _input_layout_yaxis === void 0 ? void 0 : _input_layout_yaxis.type) === 'date' ? yVal : yVal,
2024
- value: zVal,
2025
- rectText: annotationText || zVal
2026
- });
2027
- if (typeof zVal === 'number') {
2028
- zMin = Math.min(zMin, zVal);
2029
- zMax = Math.max(zMax, zVal);
2030
- }
2031
- });
2032
- });
2033
- }
2034
- var _firstData_name;
2035
- const heatmapData = {
2036
- legend: (_firstData_name = firstData.name) !== null && _firstData_name !== void 0 ? _firstData_name : '',
2037
- data: heatmapDataPoints,
2038
- value: 0
2039
- };
2040
- // Initialize domain and range to default values
2041
- const defaultDomain = [
2042
- zMin,
2043
- (zMax + zMin) / 2,
2044
- zMax
2045
- ];
2046
- const defaultRange = [
2047
- getColorFromToken(DataVizPalette.color1),
2048
- getColorFromToken(DataVizPalette.color2),
2049
- getColorFromToken(DataVizPalette.color3)
2050
- ];
2051
- var _firstData_colorscale, _ref, _ref1, _ref2, _ref3;
2052
- let colorscale = (_ref3 = (_ref2 = (_ref1 = (_ref = (_firstData_colorscale = firstData === null || firstData === void 0 ? void 0 : firstData.colorscale) !== null && _firstData_colorscale !== void 0 ? _firstData_colorscale : (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.colorscale) !== null && _ref !== void 0 ? _ref : (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : (_input_layout_coloraxis = _input_layout2.coloraxis) === null || _input_layout_coloraxis === void 0 ? void 0 : _input_layout_coloraxis.colorscale) !== null && _ref1 !== void 0 ? _ref1 : (_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : (_input_layout_template = _input_layout3.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorscale) !== null && _ref2 !== void 0 ? _ref2 : firstData.type === 'histogram2d' && ((_input_layout4 = input.layout) === null || _input_layout4 === void 0 ? void 0 : (_input_layout_template1 = _input_layout4.template) === null || _input_layout_template1 === void 0 ? void 0 : (_input_layout_template_data = _input_layout_template1.data) === null || _input_layout_template_data === void 0 ? void 0 : (_input_layout_template_data_histogram2d = _input_layout_template_data.histogram2d) === null || _input_layout_template_data_histogram2d === void 0 ? void 0 : (_input_layout_template_data_histogram2d_ = _input_layout_template_data_histogram2d[0]) === null || _input_layout_template_data_histogram2d_ === void 0 ? void 0 : _input_layout_template_data_histogram2d_.colorscale)) !== null && _ref3 !== void 0 ? _ref3 : (_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : (_input_layout_template2 = _input_layout5.template) === null || _input_layout_template2 === void 0 ? void 0 : (_input_layout_template_data1 = _input_layout_template2.data) === null || _input_layout_template_data1 === void 0 ? void 0 : (_input_layout_template_data_heatmap = _input_layout_template_data1.heatmap) === null || _input_layout_template_data_heatmap === void 0 ? void 0 : (_input_layout_template_data_heatmap_ = _input_layout_template_data_heatmap[0]) === null || _input_layout_template_data_heatmap_ === void 0 ? void 0 : _input_layout_template_data_heatmap_.colorscale;
2053
- // determine if the types diverging, sequential or sequentialminus are present in colorscale
2054
- if (colorscale && typeof colorscale === 'object' && ('diverging' in colorscale || 'sequential' in colorscale || 'sequentialminus' in colorscale)) {
2055
- const isDivergent = zMin < 0 && zMax > 0; // Data spans both positive and negative values
2056
- const isSequential = zMin >= 0; // Data is entirely positive
2057
- const isSequentialMinus = zMax <= 0; // Data is entirely negative
2058
- if (isDivergent) {
2059
- colorscale = colorscale === null || colorscale === void 0 ? void 0 : colorscale.diverging;
2060
- } else if (isSequential) {
2061
- colorscale = colorscale === null || colorscale === void 0 ? void 0 : colorscale.sequential;
2062
- } else if (isSequentialMinus) {
2063
- colorscale = colorscale === null || colorscale === void 0 ? void 0 : colorscale.sequentialminus;
2064
- }
2065
- }
2066
- const domainValuesForColorScale = Array.isArray(colorscale) ? colorscale.map((arr)=>arr[0] * (zMax - zMin) + zMin) : defaultDomain;
2067
- const rangeValuesForColorScale = Array.isArray(colorscale) ? colorscale.map((arr)=>arr[1]) : defaultRange;
2068
- var _input_layout_height;
2069
- return {
2070
- data: [
2071
- heatmapData
2072
- ],
2073
- domainValuesForColorScale,
2074
- rangeValuesForColorScale,
2075
- hideLegend: true,
2076
- showYAxisLables: true,
2077
- sortOrder: 'none',
2078
- width: (_input_layout6 = input.layout) === null || _input_layout6 === void 0 ? void 0 : _input_layout6.width,
2079
- height: (_input_layout_height = (_input_layout7 = input.layout) === null || _input_layout7 === void 0 ? void 0 : _input_layout7.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
2080
- hideTickOverlap: true,
2081
- noOfCharsToTruncate: 20,
2082
- showYAxisLablesTooltip: true,
2083
- ...getTitles(input.layout),
2084
- ...getAxisCategoryOrderProps([
2085
- firstData
2086
- ], input.layout),
2087
- ...getAxisTickProps(input.data, input.layout)
2088
- };
2089
- };
2090
- export const transformPlotlyJsonToSankeyProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
2091
- var _input_layout_template_layout, _input_layout_template, _input_layout, _input_layout_template_layout1, _input_layout_template1, _input_layout1, _node_label, _input_layout2, _input_layout3, _input_layout4;
2092
- const { link, node } = input.data[0];
2093
- var _link_value;
2094
- const validLinks = ((_link_value = link === null || link === void 0 ? void 0 : link.value) !== null && _link_value !== void 0 ? _link_value : []).map((val, index)=>{
2095
- var _link_source, _link_target;
2096
- if (isInvalidValue(val) || isInvalidValue(link === null || link === void 0 ? void 0 : (_link_source = link.source) === null || _link_source === void 0 ? void 0 : _link_source[index]) || isInvalidValue(link === null || link === void 0 ? void 0 : (_link_target = link.target) === null || _link_target === void 0 ? void 0 : _link_target[index])) {
2097
- return null;
2098
- }
2099
- return {
2100
- value: val,
2101
- source: link === null || link === void 0 ? void 0 : link.source[index],
2102
- target: link === null || link === void 0 ? void 0 : link.target[index]
2103
- };
2104
- })// Filter out negative nodes, unequal nodes and self-references (circular links)
2105
- .filter((x)=>x !== null && x.source >= 0 && x.target >= 0 && x.source !== x.target);
2106
- const extractedNodeColors = extractColor((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, node === null || node === void 0 ? void 0 : node.color, colorMap, isDarkTheme);
2107
- const extractedLinkColors = extractColor((_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_template1 = _input_layout1.template) === null || _input_layout_template1 === void 0 ? void 0 : (_input_layout_template_layout1 = _input_layout_template1.layout) === null || _input_layout_template_layout1 === void 0 ? void 0 : _input_layout_template_layout1.colorway, colorwayType, link === null || link === void 0 ? void 0 : link.color, colorMap, isDarkTheme);
2108
- const sankeyChartData = {
2109
- nodes: (_node_label = node.label) === null || _node_label === void 0 ? void 0 : _node_label.map((label, index)=>{
2110
- var _input_layout_template_layout, _input_layout_template, _input_layout;
2111
- const color = resolveColor(extractedNodeColors, index, label, colorMap, (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, isDarkTheme);
2112
- return {
2113
- nodeId: index,
2114
- name: label,
2115
- color
2116
- };
2117
- }),
2118
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2119
- links: validLinks.map((validLink, index)=>{
2120
- var _input_layout_template_layout, _input_layout_template, _input_layout;
2121
- const color = resolveColor(extractedLinkColors, index, validLink.target, colorMap, (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, isDarkTheme);
2122
- return {
2123
- ...validLink,
2124
- color
2125
- };
2126
- })
2127
- };
2128
- // const styles: SankeyChartProps['styles'] = {
2129
- // root: {
2130
- // ...(input.layout?.font?.size ? { fontSize: input.layout.font?.size } : {}),
2131
- // },
2132
- // };
2133
- const { chartTitle, titleStyles } = getTitles(input.layout);
2134
- var _input_layout_height;
2135
- return {
2136
- data: {
2137
- chartTitle,
2138
- SankeyChartData: sankeyChartData
2139
- },
2140
- width: (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.width,
2141
- height: (_input_layout_height = (_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : _input_layout3.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 468,
2142
- // TODO
2143
- // styles,
2144
- hideLegend: isMultiPlot || ((_input_layout4 = input.layout) === null || _input_layout4 === void 0 ? void 0 : _input_layout4.showlegend) === false,
2145
- ...titleStyles ? {
2146
- titleStyles
2147
- } : {}
2148
- };
2149
- };
2150
- export const transformPlotlyJsonToGaugeProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
2151
- var _firstData_gauge, _input_layout_template_layout, _input_layout_template, _input_layout, _firstData_gauge_steps, _firstData_gauge1, _firstData_gauge_axis_range, _firstData_gauge_axis, _firstData_gauge2, _input_layout_template_layout1, _input_layout_template1, _input_layout1, _firstData_gauge_axis1, _firstData_gauge3, _firstData_gauge_axis_range1, _firstData_gauge_axis2, _firstData_gauge4, _firstData_delta, _firstData_gauge_axis_range2, _firstData_gauge_axis3, _firstData_gauge5, _firstData_gauge_axis_range3, _firstData_gauge_axis4, _firstData_gauge6, _firstData_gauge_axis_range4, _firstData_gauge_axis5, _firstData_gauge7, _firstData_gauge_axis_range5, _firstData_gauge_axis6, _firstData_gauge8, _input_layout2, _input_layout3, _firstData_gauge_steps1, _firstData_gauge9;
2152
- const firstData = input.data[0];
2153
- const stepsColors = ((_firstData_gauge = firstData.gauge) === null || _firstData_gauge === void 0 ? void 0 : _firstData_gauge.steps) ? firstData.gauge.steps.map((step)=>step.color) : undefined;
2154
- const extractedColors = extractColor((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, stepsColors, colorMap, isDarkTheme);
2155
- var _firstData_gauge_axis_range_, _firstData_value, _firstData_gauge_axis_range_1, _firstData_value1;
2156
- const segments = ((_firstData_gauge1 = firstData.gauge) === null || _firstData_gauge1 === void 0 ? void 0 : (_firstData_gauge_steps = _firstData_gauge1.steps) === null || _firstData_gauge_steps === void 0 ? void 0 : _firstData_gauge_steps.length) ? firstData.gauge.steps.map((step, index)=>{
2157
- var _input_layout_template_layout, _input_layout_template, _input_layout, _step_range, _step_range1;
2158
- const legend = step.name || `Segment ${index + 1}`;
2159
- const color = resolveColor(extractedColors, index, legend, colorMap, (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, isDarkTheme);
2160
- return {
2161
- legend,
2162
- size: ((_step_range = step.range) === null || _step_range === void 0 ? void 0 : _step_range[1]) - ((_step_range1 = step.range) === null || _step_range1 === void 0 ? void 0 : _step_range1[0]),
2163
- color
2164
- };
2165
- }) : [
2166
- {
2167
- legend: 'Current',
2168
- size: (_firstData_value = firstData.value) !== null && _firstData_value !== void 0 ? _firstData_value : 0 - ((_firstData_gauge_axis_range_ = (_firstData_gauge2 = firstData.gauge) === null || _firstData_gauge2 === void 0 ? void 0 : (_firstData_gauge_axis = _firstData_gauge2.axis) === null || _firstData_gauge_axis === void 0 ? void 0 : (_firstData_gauge_axis_range = _firstData_gauge_axis.range) === null || _firstData_gauge_axis_range === void 0 ? void 0 : _firstData_gauge_axis_range[0]) !== null && _firstData_gauge_axis_range_ !== void 0 ? _firstData_gauge_axis_range_ : 0),
2169
- color: _getGaugeAxisColor((_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_template1 = _input_layout1.template) === null || _input_layout_template1 === void 0 ? void 0 : (_input_layout_template_layout1 = _input_layout_template1.layout) === null || _input_layout_template_layout1 === void 0 ? void 0 : _input_layout_template_layout1.colorway, colorwayType, (_firstData_gauge3 = firstData.gauge) === null || _firstData_gauge3 === void 0 ? void 0 : (_firstData_gauge_axis1 = _firstData_gauge3.axis) === null || _firstData_gauge_axis1 === void 0 ? void 0 : _firstData_gauge_axis1.color, colorMap, isDarkTheme)
2170
- },
2171
- {
2172
- legend: 'Target',
2173
- size: ((_firstData_gauge_axis_range_1 = (_firstData_gauge4 = firstData.gauge) === null || _firstData_gauge4 === void 0 ? void 0 : (_firstData_gauge_axis2 = _firstData_gauge4.axis) === null || _firstData_gauge_axis2 === void 0 ? void 0 : (_firstData_gauge_axis_range1 = _firstData_gauge_axis2.range) === null || _firstData_gauge_axis_range1 === void 0 ? void 0 : _firstData_gauge_axis_range1[1]) !== null && _firstData_gauge_axis_range_1 !== void 0 ? _firstData_gauge_axis_range_1 : 100) - ((_firstData_value1 = firstData.value) !== null && _firstData_value1 !== void 0 ? _firstData_value1 : 0),
2174
- color: DataVizPalette.disabled
2175
- }
2176
- ];
2177
- let sublabel;
2178
- let sublabelColor;
2179
- if ((_firstData_delta = firstData.delta) === null || _firstData_delta === void 0 ? void 0 : _firstData_delta.reference) {
2180
- const diff = firstData.value - firstData.delta.reference;
2181
- if (diff >= 0) {
2182
- var _input_layout_template_layout2, _input_layout_template2, _input_layout4, _firstData_delta_increasing, _firstData_delta1, _input_layout_template_layout3, _input_layout_template3, _input_layout5;
2183
- sublabel = `\u25B2 ${diff}`;
2184
- const extractedIncreasingDeltaColors = extractColor((_input_layout4 = input.layout) === null || _input_layout4 === void 0 ? void 0 : (_input_layout_template2 = _input_layout4.template) === null || _input_layout_template2 === void 0 ? void 0 : (_input_layout_template_layout2 = _input_layout_template2.layout) === null || _input_layout_template_layout2 === void 0 ? void 0 : _input_layout_template_layout2.colorway, colorwayType, (_firstData_delta1 = firstData.delta) === null || _firstData_delta1 === void 0 ? void 0 : (_firstData_delta_increasing = _firstData_delta1.increasing) === null || _firstData_delta_increasing === void 0 ? void 0 : _firstData_delta_increasing.color, colorMap, isDarkTheme);
2185
- const color = resolveColor(extractedIncreasingDeltaColors, 0, '', colorMap, (_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : (_input_layout_template3 = _input_layout5.template) === null || _input_layout_template3 === void 0 ? void 0 : (_input_layout_template_layout3 = _input_layout_template3.layout) === null || _input_layout_template_layout3 === void 0 ? void 0 : _input_layout_template_layout3.colorway, isDarkTheme);
2186
- sublabelColor = color;
2187
- } else {
2188
- var _input_layout_template_layout4, _input_layout_template4, _input_layout6, _firstData_delta_decreasing, _firstData_delta2, _input_layout_template_layout5, _input_layout_template5, _input_layout7;
2189
- sublabel = `\u25BC ${Math.abs(diff)}`;
2190
- const extractedDecreasingDeltaColors = extractColor((_input_layout6 = input.layout) === null || _input_layout6 === void 0 ? void 0 : (_input_layout_template4 = _input_layout6.template) === null || _input_layout_template4 === void 0 ? void 0 : (_input_layout_template_layout4 = _input_layout_template4.layout) === null || _input_layout_template_layout4 === void 0 ? void 0 : _input_layout_template_layout4.colorway, colorwayType, (_firstData_delta2 = firstData.delta) === null || _firstData_delta2 === void 0 ? void 0 : (_firstData_delta_decreasing = _firstData_delta2.decreasing) === null || _firstData_delta_decreasing === void 0 ? void 0 : _firstData_delta_decreasing.color, colorMap, isDarkTheme);
2191
- const color = resolveColor(extractedDecreasingDeltaColors, 0, '', colorMap, (_input_layout7 = input.layout) === null || _input_layout7 === void 0 ? void 0 : (_input_layout_template5 = _input_layout7.template) === null || _input_layout_template5 === void 0 ? void 0 : (_input_layout_template_layout5 = _input_layout_template5.layout) === null || _input_layout_template_layout5 === void 0 ? void 0 : _input_layout_template_layout5.colorway, isDarkTheme);
2192
- sublabelColor = color;
2193
- }
2194
- }
2195
- const styles = {
2196
- sublabel: sublabelColor
2197
- };
2198
- const { chartTitle, titleStyles } = getTitles(input.layout);
2199
- var _firstData_value2, _input_layout_height;
2200
- return {
2201
- segments,
2202
- chartValue: (_firstData_value2 = firstData.value) !== null && _firstData_value2 !== void 0 ? _firstData_value2 : 0,
2203
- chartTitle,
2204
- sublabel,
2205
- // range values can be null
2206
- minValue: typeof ((_firstData_gauge5 = firstData.gauge) === null || _firstData_gauge5 === void 0 ? void 0 : (_firstData_gauge_axis3 = _firstData_gauge5.axis) === null || _firstData_gauge_axis3 === void 0 ? void 0 : (_firstData_gauge_axis_range2 = _firstData_gauge_axis3.range) === null || _firstData_gauge_axis_range2 === void 0 ? void 0 : _firstData_gauge_axis_range2[0]) === 'number' ? (_firstData_gauge6 = firstData.gauge) === null || _firstData_gauge6 === void 0 ? void 0 : (_firstData_gauge_axis4 = _firstData_gauge6.axis) === null || _firstData_gauge_axis4 === void 0 ? void 0 : (_firstData_gauge_axis_range3 = _firstData_gauge_axis4.range) === null || _firstData_gauge_axis_range3 === void 0 ? void 0 : _firstData_gauge_axis_range3[0] : undefined,
2207
- maxValue: typeof ((_firstData_gauge7 = firstData.gauge) === null || _firstData_gauge7 === void 0 ? void 0 : (_firstData_gauge_axis5 = _firstData_gauge7.axis) === null || _firstData_gauge_axis5 === void 0 ? void 0 : (_firstData_gauge_axis_range4 = _firstData_gauge_axis5.range) === null || _firstData_gauge_axis_range4 === void 0 ? void 0 : _firstData_gauge_axis_range4[1]) === 'number' ? (_firstData_gauge8 = firstData.gauge) === null || _firstData_gauge8 === void 0 ? void 0 : (_firstData_gauge_axis6 = _firstData_gauge8.axis) === null || _firstData_gauge_axis6 === void 0 ? void 0 : (_firstData_gauge_axis_range5 = _firstData_gauge_axis6.range) === null || _firstData_gauge_axis_range5 === void 0 ? void 0 : _firstData_gauge_axis_range5[1] : undefined,
2208
- chartValueFormat: ()=>{
2209
- var _firstData_value;
2210
- var _firstData_value_toString;
2211
- return (_firstData_value_toString = (_firstData_value = firstData.value) === null || _firstData_value === void 0 ? void 0 : _firstData_value.toString()) !== null && _firstData_value_toString !== void 0 ? _firstData_value_toString : '';
2212
- },
2213
- width: (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.width,
2214
- height: (_input_layout_height = (_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : _input_layout3.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 220,
2215
- // TODO
2216
- // styles,
2217
- variant: ((_firstData_gauge9 = firstData.gauge) === null || _firstData_gauge9 === void 0 ? void 0 : (_firstData_gauge_steps1 = _firstData_gauge9.steps) === null || _firstData_gauge_steps1 === void 0 ? void 0 : _firstData_gauge_steps1.length) ? 'multiple-segments' : 'single-segment',
2218
- styles,
2219
- roundCorners: true,
2220
- ...titleStyles ? {
2221
- titleStyles
2222
- } : {}
2223
- };
2224
- };
2225
- const cleanText = (text)=>{
2226
- return text.replace(/&lt;[^&]*?&gt;/g, '').replace(/<[^>]*>/g, '').replace(/&lt;br&gt;|\\u003cbr\\u003e|<br>/gi, '').replace(/\$[^$]*\$/g, '$').trim();
2227
- };
2228
- const formatValue = (value, colIndex, cells)=>{
2229
- if (value === null || typeof value === 'boolean') {
2230
- return value;
2231
- }
2232
- const formatStr = Array.isArray(cells.format) ? cells.format[colIndex] : cells.format;
2233
- const prefix = Array.isArray(cells.prefix) ? cells.prefix[colIndex] : cells.prefix;
2234
- const suffix = Array.isArray(cells.suffix) ? cells.suffix[colIndex] : cells.suffix;
2235
- let formatted = value;
2236
- if (typeof value === 'number') {
2237
- if (typeof formatStr === 'string') {
2238
- try {
2239
- formatted = d3Format(formatStr)(value);
2240
- } catch {
2241
- formatted = formatScientificLimitWidth(value);
2242
- }
2243
- } else {
2244
- formatted = formatScientificLimitWidth(value);
2245
- }
2246
- }
2247
- return `${prefix !== null && prefix !== void 0 ? prefix : ''}${formatted}${suffix !== null && suffix !== void 0 ? suffix : ''}`;
2248
- };
2249
- function resolveCellStyle(raw, rowIndex, colIndex) {
2250
- if (Array.isArray(raw)) {
2251
- var _raw_colIndex;
2252
- const rowEntry = (_raw_colIndex = raw[colIndex]) !== null && _raw_colIndex !== void 0 ? _raw_colIndex : raw[0];
2253
- if (Array.isArray(rowEntry)) {
2254
- var _rowEntry_rowIndex;
2255
- return (_rowEntry_rowIndex = rowEntry[rowIndex]) !== null && _rowEntry_rowIndex !== void 0 ? _rowEntry_rowIndex : rowEntry[0];
2256
- }
2257
- return rowEntry;
2258
- }
2259
- return raw;
2260
- }
2261
- function mergeCells(tableCells, templateCells) {
2262
- var _tableCells_values, _ref, _tableCells_align, _templateCells_fill, _tableCells_fill, _templateCells_font, _tableCells_font, _tableCells_format, _tableCells_prefix, _tableCells_suffix;
2263
- return {
2264
- values: (_ref = (_tableCells_values = tableCells === null || tableCells === void 0 ? void 0 : tableCells.values) !== null && _tableCells_values !== void 0 ? _tableCells_values : templateCells === null || templateCells === void 0 ? void 0 : templateCells.values) !== null && _ref !== void 0 ? _ref : [],
2265
- align: (_tableCells_align = tableCells === null || tableCells === void 0 ? void 0 : tableCells.align) !== null && _tableCells_align !== void 0 ? _tableCells_align : templateCells === null || templateCells === void 0 ? void 0 : templateCells.align,
2266
- fill: {
2267
- ...(_templateCells_fill = templateCells === null || templateCells === void 0 ? void 0 : templateCells.fill) !== null && _templateCells_fill !== void 0 ? _templateCells_fill : {},
2268
- ...(_tableCells_fill = tableCells === null || tableCells === void 0 ? void 0 : tableCells.fill) !== null && _tableCells_fill !== void 0 ? _tableCells_fill : {}
2269
- },
2270
- font: {
2271
- ...(_templateCells_font = templateCells === null || templateCells === void 0 ? void 0 : templateCells.font) !== null && _templateCells_font !== void 0 ? _templateCells_font : {},
2272
- ...(_tableCells_font = tableCells === null || tableCells === void 0 ? void 0 : tableCells.font) !== null && _tableCells_font !== void 0 ? _tableCells_font : {}
2273
- },
2274
- format: (_tableCells_format = tableCells === null || tableCells === void 0 ? void 0 : tableCells.format) !== null && _tableCells_format !== void 0 ? _tableCells_format : templateCells === null || templateCells === void 0 ? void 0 : templateCells.format,
2275
- prefix: (_tableCells_prefix = tableCells === null || tableCells === void 0 ? void 0 : tableCells.prefix) !== null && _tableCells_prefix !== void 0 ? _tableCells_prefix : templateCells === null || templateCells === void 0 ? void 0 : templateCells.prefix,
2276
- suffix: (_tableCells_suffix = tableCells === null || tableCells === void 0 ? void 0 : tableCells.suffix) !== null && _tableCells_suffix !== void 0 ? _tableCells_suffix : templateCells === null || templateCells === void 0 ? void 0 : templateCells.suffix
2277
- };
2278
- }
2279
- export const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
2280
- var _tableData_cells, _input_layout_template_data_table_, _input_layout_template_data_table, _input_layout_template_data, _input_layout_template, _input_layout, _input_layout_font, _input_layout1, _input_layout_template_data_table_1, _input_layout_template_data_table1, _input_layout_template_data1, _input_layout_template1, _input_layout2, _tableData_header, _input_layout3, _input_layout4;
2281
- const tableData = input.data[0];
2282
- const normalizeHeaders = (values, header)=>{
2283
- const cleanedValues = Array.isArray(values[0]) ? values.map((row)=>row.map((cell)=>cleanText(cell)).filter(Boolean).join(' ')) : values.map((cell)=>cleanText(cell));
2284
- return cleanedValues.map((value, colIndex)=>{
2285
- var _header_font, _header_font1, _header_fill;
2286
- //headers are at first row only
2287
- const rowIndex = 0;
2288
- const fontColor = resolveCellStyle(header === null || header === void 0 ? void 0 : (_header_font = header.font) === null || _header_font === void 0 ? void 0 : _header_font.color, rowIndex, colIndex);
2289
- const fontSize = resolveCellStyle(header === null || header === void 0 ? void 0 : (_header_font1 = header.font) === null || _header_font1 === void 0 ? void 0 : _header_font1.size, rowIndex, colIndex);
2290
- const backgroundColor = resolveCellStyle(header === null || header === void 0 ? void 0 : (_header_fill = header.fill) === null || _header_fill === void 0 ? void 0 : _header_fill.color, rowIndex, colIndex);
2291
- const textAlign = resolveCellStyle(header === null || header === void 0 ? void 0 : header.align, rowIndex, colIndex);
2292
- const style = {
2293
- ...typeof fontColor === 'string' ? {
2294
- color: fontColor
2295
- } : {},
2296
- ...typeof fontSize === 'number' ? {
2297
- fontSize
2298
- } : {},
2299
- ...typeof backgroundColor === 'string' ? {
2300
- backgroundColor
2301
- } : {},
2302
- ...textAlign ? {
2303
- textAlign
2304
- } : {}
2305
- };
2306
- return {
2307
- value,
2308
- style
2309
- };
2310
- });
2311
- };
2312
- var _tableData_cells_values;
2313
- const columns = (_tableData_cells_values = (_tableData_cells = tableData.cells) === null || _tableData_cells === void 0 ? void 0 : _tableData_cells.values) !== null && _tableData_cells_values !== void 0 ? _tableData_cells_values : [];
2314
- const cells = mergeCells(tableData.cells, (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_data = _input_layout_template.data) === null || _input_layout_template_data === void 0 ? void 0 : (_input_layout_template_data_table = _input_layout_template_data.table) === null || _input_layout_template_data_table === void 0 ? void 0 : (_input_layout_template_data_table_ = _input_layout_template_data_table[0]) === null || _input_layout_template_data_table_ === void 0 ? void 0 : _input_layout_template_data_table_.cells);
2315
- const rows = columns[0].map((_, rowIndex)=>columns.map((col, colIndex)=>{
2316
- var _cells_font, _cells_font1, _cells_fill;
2317
- const cellValue = col[rowIndex];
2318
- const cleanValue = typeof cellValue === 'string' ? cleanText(cellValue) : cellValue;
2319
- const formattedValue = typeof cleanValue === 'string' || typeof cleanValue === 'number' ? formatValue(cleanValue, colIndex, cells) : cleanValue;
2320
- const fontColor = resolveCellStyle(cells === null || cells === void 0 ? void 0 : (_cells_font = cells.font) === null || _cells_font === void 0 ? void 0 : _cells_font.color, rowIndex, colIndex);
2321
- const fontSize = resolveCellStyle(cells === null || cells === void 0 ? void 0 : (_cells_font1 = cells.font) === null || _cells_font1 === void 0 ? void 0 : _cells_font1.size, rowIndex, colIndex);
2322
- const backgroundColor = resolveCellStyle(cells === null || cells === void 0 ? void 0 : (_cells_fill = cells.fill) === null || _cells_fill === void 0 ? void 0 : _cells_fill.color, rowIndex, colIndex);
2323
- const textAlign = resolveCellStyle(cells === null || cells === void 0 ? void 0 : cells.align, rowIndex, colIndex);
2324
- const style = {
2325
- ...fontColor ? {
2326
- color: fontColor
2327
- } : {},
2328
- ...typeof fontSize === 'number' ? {
2329
- fontSize
2330
- } : {},
2331
- ...backgroundColor ? {
2332
- backgroundColor
2333
- } : {},
2334
- ...textAlign ? {
2335
- textAlign
2336
- } : {}
2337
- };
2338
- return {
2339
- value: formattedValue,
2340
- style
2341
- };
2342
- }));
2343
- const styles = {
2344
- root: {
2345
- ...((_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_font = _input_layout1.font) === null || _input_layout_font === void 0 ? void 0 : _input_layout_font.size) ? {
2346
- fontSize: input.layout.font.size
2347
- } : {}
2348
- }
2349
- };
2350
- const templateHeader = (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : (_input_layout_template1 = _input_layout2.template) === null || _input_layout_template1 === void 0 ? void 0 : (_input_layout_template_data1 = _input_layout_template1.data) === null || _input_layout_template_data1 === void 0 ? void 0 : (_input_layout_template_data_table1 = _input_layout_template_data1.table) === null || _input_layout_template_data_table1 === void 0 ? void 0 : (_input_layout_template_data_table_1 = _input_layout_template_data_table1[0]) === null || _input_layout_template_data_table_1 === void 0 ? void 0 : _input_layout_template_data_table_1.header;
2351
- const tableHeader = tableData.header;
2352
- var _tableHeader_align, _templateHeader_fill, _tableHeader_fill, _templateHeader_font, _tableHeader_font, _tableHeader_values, _ref;
2353
- const header = {
2354
- align: (_tableHeader_align = tableHeader === null || tableHeader === void 0 ? void 0 : tableHeader.align) !== null && _tableHeader_align !== void 0 ? _tableHeader_align : templateHeader === null || templateHeader === void 0 ? void 0 : templateHeader.align,
2355
- fill: {
2356
- ...(_templateHeader_fill = templateHeader === null || templateHeader === void 0 ? void 0 : templateHeader.fill) !== null && _templateHeader_fill !== void 0 ? _templateHeader_fill : {},
2357
- ...(_tableHeader_fill = tableHeader === null || tableHeader === void 0 ? void 0 : tableHeader.fill) !== null && _tableHeader_fill !== void 0 ? _tableHeader_fill : {}
2358
- },
2359
- font: {
2360
- ...(_templateHeader_font = templateHeader === null || templateHeader === void 0 ? void 0 : templateHeader.font) !== null && _templateHeader_font !== void 0 ? _templateHeader_font : {},
2361
- ...(_tableHeader_font = tableHeader === null || tableHeader === void 0 ? void 0 : tableHeader.font) !== null && _tableHeader_font !== void 0 ? _tableHeader_font : {}
2362
- },
2363
- values: (_ref = (_tableHeader_values = tableHeader === null || tableHeader === void 0 ? void 0 : tableHeader.values) !== null && _tableHeader_values !== void 0 ? _tableHeader_values : templateHeader === null || templateHeader === void 0 ? void 0 : templateHeader.values) !== null && _ref !== void 0 ? _ref : []
2364
- };
2365
- const { chartTitle, titleStyles } = getTitles(input.layout);
2366
- var _tableData_header_values;
2367
- return {
2368
- headers: normalizeHeaders((_tableData_header_values = (_tableData_header = tableData.header) === null || _tableData_header === void 0 ? void 0 : _tableData_header.values) !== null && _tableData_header_values !== void 0 ? _tableData_header_values : [], header),
2369
- rows,
2370
- width: (_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : _input_layout3.width,
2371
- height: (_input_layout4 = input.layout) === null || _input_layout4 === void 0 ? void 0 : _input_layout4.height,
2372
- styles,
2373
- chartTitle,
2374
- ...titleStyles ? {
2375
- titleStyles
2376
- } : {}
2377
- };
2378
- };
2379
- function getCategoriesAndValues(series) {
2380
- const orientation = series.orientation || 'h';
2381
- var _series_labels, _ref;
2382
- const y = (_ref = (_series_labels = series.labels) !== null && _series_labels !== void 0 ? _series_labels : series.y) !== null && _ref !== void 0 ? _ref : series.stage;
2383
- var _series_values, _ref1;
2384
- const x = (_ref1 = (_series_values = series.values) !== null && _series_values !== void 0 ? _series_values : series.x) !== null && _ref1 !== void 0 ? _ref1 : series.value;
2385
- const xIsString = isStringArray(x);
2386
- const yIsString = isStringArray(y);
2387
- const xIsNumber = isNumberArray(x);
2388
- const yIsNumber = isNumberArray(y);
2389
- // Helper to ensure array of (string | number)
2390
- const toArray = (arr)=>{
2391
- if (Array.isArray(arr)) {
2392
- return arr;
2393
- }
2394
- if (typeof arr === 'string' || typeof arr === 'number') {
2395
- return [
2396
- arr
2397
- ];
2398
- }
2399
- return [];
2400
- };
2401
- if (orientation === 'h') {
2402
- if (yIsString && xIsNumber) {
2403
- return {
2404
- categories: toArray(y),
2405
- values: toArray(x)
2406
- };
2407
- } else if (xIsString && yIsNumber) {
2408
- return {
2409
- categories: toArray(x),
2410
- values: toArray(y)
2411
- };
2412
- } else {
2413
- return {
2414
- categories: yIsString ? toArray(y) : toArray(x),
2415
- values: yIsString ? toArray(x) : toArray(y)
2416
- };
2417
- }
2418
- } else {
2419
- if (xIsString && yIsNumber) {
2420
- return {
2421
- categories: toArray(x),
2422
- values: toArray(y)
2423
- };
2424
- } else if (yIsString && xIsNumber) {
2425
- return {
2426
- categories: toArray(y),
2427
- values: toArray(x)
2428
- };
2429
- } else {
2430
- return {
2431
- categories: xIsString ? toArray(x) : toArray(y),
2432
- values: xIsString ? toArray(y) : toArray(x)
2433
- };
2434
- }
2435
- }
2436
- }
2437
- export const transformPlotlyJsonToFunnelChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
2438
- var _input_layout, _input_layout1, _input_data_, _input_layout2;
2439
- const funnelData = [];
2440
- // Determine if data is stacked based on multiple series with multiple values per series
2441
- const isStacked = input.data.length > 1 && input.data.every((series)=>{
2442
- var _series_values, _ref;
2443
- const values = (_ref = (_series_values = series.values) !== null && _series_values !== void 0 ? _series_values : series.x) !== null && _ref !== void 0 ? _ref : series.value;
2444
- var _series_labels, _ref1;
2445
- const labels = (_ref1 = (_series_labels = series.labels) !== null && _series_labels !== void 0 ? _series_labels : series.y) !== null && _ref1 !== void 0 ? _ref1 : series.stage;
2446
- return Array.isArray(labels) && Array.isArray(values) && values.length > 1 && labels.length > 1;
2447
- });
2448
- if (isStacked) {
2449
- // Assign a color per series/category and use it for all subValues of that category
2450
- const seriesColors = {};
2451
- input.data.forEach((series, seriesIdx)=>{
2452
- var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _series_marker1, _input_layout_template_layout1, _input_layout_template1, _input_layout1;
2453
- const category = series.name || `Category ${seriesIdx + 1}`;
2454
- var _series_marker_colors;
2455
- // Use the same color for this category across all stages
2456
- const extractedColors = extractColor((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_series_marker_colors = (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.colors) !== null && _series_marker_colors !== void 0 ? _series_marker_colors : (_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color, colorMap, isDarkTheme);
2457
- // Always use the first color for the series/category
2458
- const color = resolveColor(extractedColors, 0, category, colorMap, (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_template1 = _input_layout1.template) === null || _input_layout_template1 === void 0 ? void 0 : (_input_layout_template_layout1 = _input_layout_template1.layout) === null || _input_layout_template_layout1 === void 0 ? void 0 : _input_layout_template_layout1.colorway, isDarkTheme);
2459
- seriesColors[category] = color;
2460
- var _series_labels, _ref;
2461
- const labels = (_ref = (_series_labels = series.labels) !== null && _series_labels !== void 0 ? _series_labels : series.y) !== null && _ref !== void 0 ? _ref : series.stage;
2462
- var _series_values, _ref1;
2463
- const values = (_ref1 = (_series_values = series.values) !== null && _series_values !== void 0 ? _series_values : series.x) !== null && _ref1 !== void 0 ? _ref1 : series.value;
2464
- if (!isArrayOrTypedArray(labels) || !isArrayOrTypedArray(values)) {
2465
- return;
2466
- }
2467
- if (labels && isArrayOrTypedArray(labels) && labels.length > 0) {
2468
- labels.forEach((label, i)=>{
2469
- const stageIndex = funnelData.findIndex((stage)=>stage.stage === label);
2470
- const valueNum = Number(values[i]);
2471
- if (isNaN(valueNum)) {
2472
- return;
2473
- }
2474
- if (stageIndex === -1) {
2475
- funnelData.push({
2476
- stage: label,
2477
- subValues: [
2478
- {
2479
- category,
2480
- value: valueNum,
2481
- color
2482
- }
2483
- ]
2484
- });
2485
- } else {
2486
- funnelData[stageIndex].subValues.push({
2487
- category,
2488
- value: valueNum,
2489
- color
2490
- });
2491
- }
2492
- });
2493
- }
2494
- });
2495
- } else {
2496
- // Non-stacked data handling (multiple series with single-value arrays)
2497
- input.data.forEach((series, seriesIdx)=>{
2498
- var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _series_marker1;
2499
- const { categories, values } = getCategoriesAndValues(series);
2500
- if (!isArrayOrTypedArray(categories) || !isArrayOrTypedArray(values)) {
2501
- return;
2502
- }
2503
- var _series_marker_colors;
2504
- const extractedColors = extractColor((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_series_marker_colors = (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.colors) !== null && _series_marker_colors !== void 0 ? _series_marker_colors : (_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color, colorMap, isDarkTheme);
2505
- categories.forEach((label, i)=>{
2506
- var _input_layout_template_layout, _input_layout_template, _input_layout;
2507
- const color = resolveColor(extractedColors, i, label, colorMap, (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, isDarkTheme);
2508
- const valueNum = Number(values[i]);
2509
- if (isNaN(valueNum)) {
2510
- return;
2511
- }
2512
- funnelData.push({
2513
- stage: label,
2514
- value: valueNum,
2515
- color
2516
- });
2517
- });
2518
- });
2519
- }
2520
- const { chartTitle, titleStyles } = getTitles(input.layout);
2521
- return {
2522
- data: funnelData,
2523
- chartTitle,
2524
- width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
2525
- height: (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.height,
2526
- orientation: ((_input_data_ = input.data[0]) === null || _input_data_ === void 0 ? void 0 : _input_data_.orientation) === 'v' ? 'horizontal' : 'vertical',
2527
- hideLegend: isMultiPlot || ((_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.showlegend) === false,
2528
- ...titleStyles ? {
2529
- titleStyles
2530
- } : {}
2531
- };
2532
- };
2533
- export const transformPlotlyJsonToPolarChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
2534
- var _input_layout, _input_layout1;
2535
- const polarData = [];
2536
- const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
2537
- const resolveRValue = getAxisValueResolver(getPolarAxis(input.data, 'r', input.layout)._type);
2538
- input.data.forEach((series, index)=>{
2539
- const legend = legends[index];
2540
- if (series.type === 'scatterpolar') {
2541
- var _series_line, _series_marker, _input_layout_template_layout, _input_layout_template, _input_layout, _input_layout_template_layout1, _input_layout_template1, _input_layout1, _series_r;
2542
- const isAreaTrace = series.fill === 'toself' || series.fill === 'tonext';
2543
- const isLineTrace = typeof series.mode === 'undefined' ? true : series.mode.includes('lines');
2544
- const colors = isAreaTrace ? series.fillcolor : isLineTrace ? (_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.color : (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color;
2545
- const extractedColors = extractColor((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, colors, colorMap, isDarkTheme);
2546
- const seriesColor = resolveColor(extractedColors, index, legend, colorMap, (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_template1 = _input_layout1.template) === null || _input_layout_template1 === void 0 ? void 0 : (_input_layout_template_layout1 = _input_layout_template1.layout) === null || _input_layout_template_layout1 === void 0 ? void 0 : _input_layout_template_layout1.colorway, isDarkTheme);
2547
- const seriesOpacity = getOpacity(series, index);
2548
- const finalSeriesColor = rgb(seriesColor).copy({
2549
- opacity: seriesOpacity
2550
- }).formatHex8();
2551
- const lineOptions = getLineOptions(series.line);
2552
- const thetaUnit = series.thetaunit;
2553
- const commonProps = {
2554
- legend,
2555
- legendShape: getLegendShape(series),
2556
- color: finalSeriesColor,
2557
- data: ((_series_r = series.r) === null || _series_r === void 0 ? void 0 : _series_r.map((r, rIndex)=>{
2558
- var _series_theta, _series_marker, _series_marker1, _input_layout_template_layout, _input_layout_template, _input_layout;
2559
- const theta = (_series_theta = series.theta) === null || _series_theta === void 0 ? void 0 : _series_theta[rIndex];
2560
- const markerSize = Array.isArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.size) ? series.marker.size[rIndex] : (_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.size;
2561
- const text = Array.isArray(series.text) ? series.text[rIndex] : series.text;
2562
- const markerColor = resolveColor(extractedColors, rIndex, legend, colorMap, (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, isDarkTheme);
2563
- const markerOpacity = getOpacity(series, rIndex);
2564
- if (isInvalidValue(resolveRValue(r)) || isInvalidValue(theta)) {
2565
- return;
2566
- }
2567
- return {
2568
- r: resolveRValue(r),
2569
- theta: typeof theta === 'number' ? thetaUnit === 'radians' ? theta * 180 / Math.PI : thetaUnit === 'gradians' ? theta * 0.9 : theta : theta,
2570
- color: markerColor ? rgb(markerColor).copy({
2571
- opacity: markerOpacity
2572
- }).formatHex8() : finalSeriesColor,
2573
- ...typeof markerSize !== 'undefined' ? {
2574
- markerSize
2575
- } : {},
2576
- ...typeof text !== 'undefined' ? {
2577
- text
2578
- } : {}
2579
- };
2580
- }).filter((item)=>typeof item !== 'undefined')) || []
2581
- };
2582
- if (isAreaTrace || isLineTrace) {
2583
- polarData.push({
2584
- type: isAreaTrace ? 'areapolar' : 'linepolar',
2585
- ...commonProps,
2586
- lineOptions
2587
- });
2588
- } else {
2589
- polarData.push({
2590
- type: 'scatterpolar',
2591
- ...commonProps
2592
- });
2593
- }
2594
- }
2595
- });
2596
- var _input_layout_height;
2597
- return {
2598
- data: polarData,
2599
- width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
2600
- height: (_input_layout_height = (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 400,
2601
- hideLegend,
2602
- ...getPolarAxisProps(input.data, input.layout)
2603
- };
2604
- };
2605
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2606
- function isPlainObject(obj) {
2607
- return Object.prototype.toString.call(obj) === '[object Object]' && Object.getPrototypeOf(obj).hasOwnProperty('hasOwnProperty');
2608
- }
2609
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2610
- var arrayAttributes = [];
2611
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2612
- var stack = [];
2613
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2614
- var isArrayStack = [];
2615
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2616
- var baseContainer, baseAttrName;
2617
- /**
2618
- * Interate iteratively through the trace object and find all the array attributes.
2619
- * 1 trace record = 1 series of data
2620
- * @param trace
2621
- */ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2622
- export function findArrayAttributes(trace) {
2623
- // Init basecontainer and baseAttrName
2624
- crawlIntoTrace(baseContainer, 0, '');
2625
- }
2626
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2627
- function crawlIntoTrace(container, i, astrPartial) {
2628
- var item = container[stack[i]];
2629
- var newAstrPartial = astrPartial + stack[i];
2630
- if (i === stack.length - 1) {
2631
- if (isArrayOrTypedArray(item)) {
2632
- arrayAttributes.push(baseAttrName + newAstrPartial);
2633
- }
2634
- } else {
2635
- if (isArrayStack[i]) {
2636
- if (Array.isArray(item)) {
2637
- for(var j = 0; j < item.length; j++){
2638
- if (isPlainObject(item[j])) {
2639
- crawlIntoTrace(item[j], i + 1, newAstrPartial + '[' + j + '].');
2640
- }
2641
- }
2642
- }
2643
- } else if (isPlainObject(item)) {
2644
- crawlIntoTrace(item, i + 1, newAstrPartial + '.');
2645
- }
2646
- }
2647
- }
2648
- function getLineOptions(line) {
2649
- if (!line) {
2650
- return;
2651
- }
2652
- let lineOptions = {};
2653
- if (line.dash) {
2654
- lineOptions = {
2655
- ...lineOptions,
2656
- ...dashOptions[line.dash]
2657
- };
2658
- }
2659
- switch(line.shape){
2660
- case 'spline':
2661
- const smoothing = typeof line.smoothing === 'number' ? line.smoothing : 1;
2662
- lineOptions.curve = d3CurveCardinal.tension(1 - smoothing / 1.3);
2663
- break;
2664
- case 'hv':
2665
- lineOptions.curve = 'stepAfter';
2666
- break;
2667
- case 'vh':
2668
- lineOptions.curve = 'stepBefore';
2669
- break;
2670
- case 'hvh':
2671
- lineOptions.curve = 'step';
2672
- break;
2673
- default:
2674
- lineOptions.curve = 'linear';
2675
- }
2676
- return Object.keys(lineOptions).length > 0 ? lineOptions : undefined;
2677
- }
2678
- // TODO: Use binary search to find the appropriate bin for numeric value.
2679
- const findBinIndex = (bins, value, isString)=>{
2680
- if (typeof value === 'undefined' || value === null) {
2681
- return -1;
2682
- }
2683
- return isString ? bins.findIndex((bin)=>bin.includes(value)) : bins.findIndex((bin, index)=>value >= bin.x0 && (index === bins.length - 1 ? value <= bin.x1 : value < bin.x1));
2684
- };
2685
- const getBinSize = (bin)=>{
2686
- return bin.x1 - bin.x0;
2687
- };
2688
- const getBinCenter = (bin)=>{
2689
- return (bin.x1 + bin.x0) / 2;
2690
- };
2691
- // TODO: Add support for date axes
2692
- const createBins = (data, binStart, binEnd, binSize)=>{
2693
- if (!data || data.length === 0) {
2694
- return [];
2695
- }
2696
- if (isStringArray(data)) {
2697
- const categories = Array.from(new Set(data));
2698
- const start = typeof binStart === 'number' ? Math.ceil(binStart) : 0;
2699
- const stop = typeof binEnd === 'number' ? Math.floor(binEnd) + 1 : categories.length;
2700
- const step = typeof binSize === 'number' ? binSize : 1;
2701
- return d3Range(start, stop, step).map((i)=>categories.slice(i, i + step));
2702
- }
2703
- const scale = d3ScaleLinear().domain(d3Extent(data)).nice();
2704
- let [minVal, maxVal] = scale.domain();
2705
- minVal = typeof binStart === 'number' ? binStart : minVal;
2706
- maxVal = typeof binEnd === 'number' ? binEnd : maxVal;
2707
- const binGenerator = d3Bin().domain([
2708
- minVal,
2709
- maxVal
2710
- ]);
2711
- if (typeof binSize === 'number' && binSize > 0) {
2712
- const thresholds = [];
2713
- const precision = Math.max(calculatePrecision(minVal), calculatePrecision(binSize));
2714
- let th = precisionRound(minVal, precision);
2715
- while(th < precisionRound(maxVal + binSize, precision)){
2716
- thresholds.push(th);
2717
- th = precisionRound(th + binSize, precision);
2718
- }
2719
- minVal = thresholds[0];
2720
- maxVal = thresholds[thresholds.length - 1];
2721
- binGenerator.domain([
2722
- minVal,
2723
- maxVal
2724
- ]).thresholds(thresholds);
2725
- // When the domain ends at the last threshold (maxVal), d3Bin creates an extra final bin where
2726
- // both x0 and x1 are equal to maxVal and inclusive. The previous bin also has x1 equal to maxVal,
2727
- // but it is exclusive. To maintain consistent bin widths, remove the final bin,
2728
- // making the previous bin the last one, with both x0 and x1 inclusive.
2729
- return binGenerator(data).slice(0, -1);
2730
- }
2731
- return binGenerator(data);
2732
- };
2733
- const calculateHistFunc = (histfunc, bin)=>{
2734
- switch(histfunc){
2735
- case 'sum':
2736
- return d3Sum(bin);
2737
- case 'avg':
2738
- return bin.length === 0 ? 0 : d3Sum(bin) / bin.length;
2739
- case 'min':
2740
- var _d3Min;
2741
- return (_d3Min = d3Min(bin)) !== null && _d3Min !== void 0 ? _d3Min : 0;
2742
- case 'max':
2743
- var _d3Max;
2744
- return (_d3Max = d3Max(bin)) !== null && _d3Max !== void 0 ? _d3Max : 0;
2745
- default:
2746
- return bin.length;
2747
- }
2748
- };
2749
- const calculateHistNorm = (histnorm, value, total, dx, dy = 1)=>{
2750
- switch(histnorm){
2751
- case 'percent':
2752
- return total === 0 ? 0 : value / total * 100;
2753
- case 'probability':
2754
- return total === 0 ? 0 : value / total;
2755
- case 'density':
2756
- return dx * dy === 0 ? 0 : value / (dx * dy);
2757
- case 'probability density':
2758
- return total * dx * dy === 0 ? 0 : value / (total * dx * dy);
2759
- default:
2760
- return value;
2761
- }
2762
- };
2763
- const getLegendShape = (series)=>{
2764
- var _series_line, _series_mode;
2765
- const dashType = ((_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.dash) || 'solid';
2766
- if (dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot') {
2767
- return 'dottedLine';
2768
- } else if ((_series_mode = series.mode) === null || _series_mode === void 0 ? void 0 : _series_mode.includes('markers')) {
2769
- return 'circle';
2770
- }
2771
- return 'default';
2772
- };
2773
- export const getAllupLegendsProps = (input, colorMap, colorwayType, traceInfo, isDarkTheme)=>{
2774
- const allupLegends = [];
2775
- // reduce on showlegend boolean propperty. reduce should return true if at least one series has showlegend true
2776
- const toShowLegend = input.data.reduce((acc, series)=>{
2777
- return acc || series.showlegend === true || series.showlegend === undefined;
2778
- }, false);
2779
- if (toShowLegend) {
2780
- input.data.forEach((series, index)=>{
2781
- if (traceInfo[index].type === 'donut') {
2782
- var _input_layout, _input_layout_template_layout, _input_layout_template, _input_layout1, _input_layout2, _pieSeries_marker;
2783
- const pieSeries = series;
2784
- var _input_layout_piecolorway, _input_layout_piecolorway1;
2785
- const colors = extractColor((_input_layout_piecolorway = (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.piecolorway) !== null && _input_layout_piecolorway !== void 0 ? _input_layout_piecolorway : (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_template = _input_layout1.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_input_layout_piecolorway1 = (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.piecolorway) !== null && _input_layout_piecolorway1 !== void 0 ? _input_layout_piecolorway1 : pieSeries === null || pieSeries === void 0 ? void 0 : (_pieSeries_marker = pieSeries.marker) === null || _pieSeries_marker === void 0 ? void 0 : _pieSeries_marker.colors, colorMap, isDarkTheme, true);
2786
- if (isArrayOrTypedArray(pieSeries.labels)) {
2787
- pieSeries.labels.forEach((label, labelIndex)=>{
2788
- var _input_layout, _input_layout_template_layout, _input_layout_template, _input_layout1;
2789
- const legend = `${label}`;
2790
- var _input_layout_piecolorway;
2791
- // resolve color for each legend from the extracted colors
2792
- const color = resolveColor(colors, labelIndex, legend, colorMap, (_input_layout_piecolorway = (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.piecolorway) !== null && _input_layout_piecolorway !== void 0 ? _input_layout_piecolorway : (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_template = _input_layout1.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, isDarkTheme, true);
2793
- if (legend !== '' && allupLegends.some((group)=>group.title === legend) === false) {
2794
- allupLegends.push({
2795
- title: legend,
2796
- color
2797
- });
2798
- }
2799
- });
2800
- }
2801
- } else if (isNonPlotType(traceInfo[index].type) === false) {
2802
- var _plotSeries_line, _plotSeries_marker, _input_layout_template_layout1, _input_layout_template1, _input_layout3;
2803
- const plotSeries = series;
2804
- const name = plotSeries.legendgroup;
2805
- const color = ((_plotSeries_line = plotSeries.line) === null || _plotSeries_line === void 0 ? void 0 : _plotSeries_line.color) || ((_plotSeries_marker = plotSeries.marker) === null || _plotSeries_marker === void 0 ? void 0 : _plotSeries_marker.color);
2806
- const legendShape = getLegendShape(plotSeries);
2807
- const resolvedColor = extractColor((_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : (_input_layout_template1 = _input_layout3.template) === null || _input_layout_template1 === void 0 ? void 0 : (_input_layout_template_layout1 = _input_layout_template1.layout) === null || _input_layout_template_layout1 === void 0 ? void 0 : _input_layout_template_layout1.colorway, colorwayType, color, colorMap, isDarkTheme);
2808
- if (name !== undefined && name !== '' && allupLegends.some((group)=>group.title === name) === false) {
2809
- allupLegends.push({
2810
- title: name,
2811
- color: resolvedColor,
2812
- shape: legendShape
2813
- });
2814
- }
2815
- }
2816
- });
2817
- }
2818
- return {
2819
- legends: allupLegends,
2820
- centerLegends: true,
2821
- enabledWrapLines: true,
2822
- canSelectMultipleLegends: true
2823
- };
2824
- };
2825
- const getLegendProps = (data, layout, isMultiPlot)=>{
2826
- const legends = [];
2827
- if (data.length === 1) {
2828
- legends.push(data[0].name || '');
2829
- } else {
2830
- data.forEach((series, index)=>{
2831
- legends.push(series.name || `Series ${index + 1}`);
2832
- });
2833
- }
2834
- const hideLegendsData = data.every((series)=>series.showlegend === false);
2835
- const hideLegendsInferred = (layout === null || layout === void 0 ? void 0 : layout.showlegend) === false || (layout === null || layout === void 0 ? void 0 : layout.showlegend) !== true && legends.length < 2;
2836
- return {
2837
- legends,
2838
- hideLegend: isMultiPlot || hideLegendsInferred || hideLegendsData
2839
- };
2840
- };
2841
- export const getNumberAtIndexOrDefault = (data, index)=>{
2842
- if (isArrayOrTypedArray(data)) {
2843
- if (typeof data[index] !== 'number' || !isFinite(data[index])) {
2844
- return;
2845
- }
2846
- return data[index];
2847
- }
2848
- return 1;
2849
- };
2850
- export const getValidXYRanges = (series, resolveX, resolveY)=>{
2851
- if (!isArrayOrTypedArray(series.x) || !isArrayOrTypedArray(series.y)) {
2852
- return [];
2853
- }
2854
- const ranges = [];
2855
- let start = 0;
2856
- let end = 0;
2857
- for(; end < series.x.length; end++){
2858
- if (isInvalidValue(series.x[end]) || typeof resolveX === 'function' && isInvalidValue(resolveX(series.x[end])) || isInvalidValue(series.y[end]) || typeof resolveY === 'function' && isInvalidValue(resolveY(series.y[end]))) {
2859
- if (end - start > 0) {
2860
- ranges.push([
2861
- start,
2862
- end
2863
- ]);
2864
- }
2865
- start = end + 1;
2866
- }
2867
- }
2868
- if (end - start > 0) {
2869
- ranges.push([
2870
- start,
2871
- end
2872
- ]);
2873
- }
2874
- return ranges;
2875
- };
2876
- const getIndexFromKey = (key, pattern)=>{
2877
- const normalizedKey = key.replace(pattern, '') === '' ? '1' : key.replace(pattern, '');
2878
- return parseInt(normalizedKey, 10) - 1;
2879
- };
2880
- export const isNonPlotType = (chartType)=>{
2881
- return [
2882
- 'donut',
2883
- 'sankey',
2884
- 'pie',
2885
- 'annotation',
2886
- 'table',
2887
- 'gauge',
2888
- 'funnel'
2889
- ].includes(chartType);
2890
- };
2891
- export const getGridProperties = (schema, isMultiPlot, validTracesInfo)=>{
2892
- const domainX = [];
2893
- const domainY = [];
2894
- let cartesianDomains = 0;
2895
- const annotations = {};
2896
- let templateRows = '1fr';
2897
- let templateColumns = '1fr';
2898
- const gridLayout = {};
2899
- if (!isMultiPlot) {
2900
- return {
2901
- templateRows,
2902
- templateColumns,
2903
- layout: gridLayout
2904
- };
2905
- }
2906
- const layout = schema === null || schema === void 0 ? void 0 : schema.layout;
2907
- if (layout !== undefined && layout !== null && Object.keys(layout).length > 0) {
2908
- Object.keys(layout !== null && layout !== void 0 ? layout : {}).forEach((key)=>{
2909
- if (key.startsWith('xaxis')) {
2910
- var _layout_key;
2911
- const index = getIndexFromKey(key, 'xaxis');
2912
- var _layout_key_anchor;
2913
- const anchor = (_layout_key_anchor = (_layout_key = layout[key]) === null || _layout_key === void 0 ? void 0 : _layout_key.anchor) !== null && _layout_key_anchor !== void 0 ? _layout_key_anchor : 'y';
2914
- const anchorIndex = getIndexFromKey(anchor, 'y');
2915
- if (index !== anchorIndex) {
2916
- throw new Error(`Invalid layout: xaxis ${index + 1} anchor should be y${anchorIndex + 1}`);
2917
- }
2918
- const xAxisLayout = layout[key];
2919
- const domainXInfo = {
2920
- start: (xAxisLayout === null || xAxisLayout === void 0 ? void 0 : xAxisLayout.domain) ? xAxisLayout.domain[0] : 0,
2921
- end: (xAxisLayout === null || xAxisLayout === void 0 ? void 0 : xAxisLayout.domain) ? xAxisLayout.domain[1] : 1,
2922
- cellName: `x${domainX.length === 0 ? '' : domainX.length + 1}`
2923
- };
2924
- domainX.push(domainXInfo);
2925
- } else if (key.startsWith('yaxis')) {
2926
- var _layout_key1;
2927
- const index = getIndexFromKey(key, 'yaxis');
2928
- var _layout_key_anchor1;
2929
- const anchor = (_layout_key_anchor1 = (_layout_key1 = layout[key]) === null || _layout_key1 === void 0 ? void 0 : _layout_key1.anchor) !== null && _layout_key_anchor1 !== void 0 ? _layout_key_anchor1 : 'x';
2930
- const anchorIndex = getIndexFromKey(anchor, 'x');
2931
- if (index !== anchorIndex) {
2932
- var _layout_yaxis2;
2933
- if (index === 1 && anchorIndex === 0 || ((_layout_yaxis2 = layout.yaxis2) === null || _layout_yaxis2 === void 0 ? void 0 : _layout_yaxis2.side) === 'right') {
2934
- // Special case for secondary y axis where yaxis2 can anchor to x1
2935
- return {
2936
- templateRows,
2937
- templateColumns
2938
- };
2939
- }
2940
- throw new Error(`Invalid layout: yaxis ${index + 1} anchor should be x${anchorIndex + 1}`);
2941
- }
2942
- const yAxisLayout = layout[key];
2943
- const domainYInfo = {
2944
- start: (yAxisLayout === null || yAxisLayout === void 0 ? void 0 : yAxisLayout.domain) ? yAxisLayout.domain[0] : 0,
2945
- end: (yAxisLayout === null || yAxisLayout === void 0 ? void 0 : yAxisLayout.domain) ? yAxisLayout.domain[1] : 1,
2946
- cellName: `x${domainY.length === 0 ? '' : domainY.length + 1}`
2947
- };
2948
- domainY.push(domainYInfo);
2949
- }
2950
- });
2951
- }
2952
- cartesianDomains = domainX.length; // Assuming that the number of x and y axes is the same
2953
- validTracesInfo.forEach((trace, index)=>{
2954
- if (isNonPlotType(trace.type)) {
2955
- var _schema_data, _series_domain, _series_domain1, _series_domain2, _series_domain3;
2956
- const series = schema === null || schema === void 0 ? void 0 : (_schema_data = schema.data) === null || _schema_data === void 0 ? void 0 : _schema_data[index];
2957
- const domainXInfo = {
2958
- start: ((_series_domain = series.domain) === null || _series_domain === void 0 ? void 0 : _series_domain.x) ? series.domain.x[0] : 0,
2959
- end: ((_series_domain1 = series.domain) === null || _series_domain1 === void 0 ? void 0 : _series_domain1.x) ? series.domain.x[1] : 1,
2960
- cellName: `${NON_PLOT_KEY_PREFIX}${domainX.length - cartesianDomains + 1}`
2961
- };
2962
- const domainYInfo = {
2963
- start: ((_series_domain2 = series.domain) === null || _series_domain2 === void 0 ? void 0 : _series_domain2.y) ? series.domain.y[0] : 0,
2964
- end: ((_series_domain3 = series.domain) === null || _series_domain3 === void 0 ? void 0 : _series_domain3.y) ? series.domain.y[1] : 1,
2965
- cellName: `${NON_PLOT_KEY_PREFIX}${domainY.length - cartesianDomains + 1}`
2966
- };
2967
- domainX.push(domainXInfo);
2968
- domainY.push(domainYInfo);
2969
- }
2970
- });
2971
- if (layout !== undefined && layout !== null && Object.keys(layout).length > 0) {
2972
- var _layout_annotations;
2973
- Object.keys(layout !== null && layout !== void 0 ? layout : {}).forEach((key)=>{
2974
- if (key.startsWith('polar')) {
2975
- var _polarLayout_domain, _polarLayout_domain1, _polarLayout_domain2, _polarLayout_domain3;
2976
- const polarLayout = layout[key];
2977
- const domainXInfo = {
2978
- start: ((_polarLayout_domain = polarLayout.domain) === null || _polarLayout_domain === void 0 ? void 0 : _polarLayout_domain.x) ? polarLayout.domain.x[0] : 0,
2979
- end: ((_polarLayout_domain1 = polarLayout.domain) === null || _polarLayout_domain1 === void 0 ? void 0 : _polarLayout_domain1.x) ? polarLayout.domain.x[1] : 1,
2980
- cellName: key
2981
- };
2982
- const domainYInfo = {
2983
- start: ((_polarLayout_domain2 = polarLayout.domain) === null || _polarLayout_domain2 === void 0 ? void 0 : _polarLayout_domain2.y) ? polarLayout.domain.y[0] : 0,
2984
- end: ((_polarLayout_domain3 = polarLayout.domain) === null || _polarLayout_domain3 === void 0 ? void 0 : _polarLayout_domain3.y) ? polarLayout.domain.y[1] : 1,
2985
- cellName: key
2986
- };
2987
- domainX.push(domainXInfo);
2988
- domainY.push(domainYInfo);
2989
- }
2990
- });
2991
- (_layout_annotations = layout.annotations) === null || _layout_annotations === void 0 ? void 0 : _layout_annotations.forEach((annotation)=>{
2992
- const xMatches = domainX.flatMap((interval, idx)=>(annotation === null || annotation === void 0 ? void 0 : annotation.x) >= interval.start && (annotation === null || annotation === void 0 ? void 0 : annotation.x) <= interval.end ? [
2993
- idx
2994
- ] : []);
2995
- const yMatch = domainY.findIndex((interval, yIndex)=>xMatches.includes(yIndex) && (annotation === null || annotation === void 0 ? void 0 : annotation.y) >= interval.start && (annotation === null || annotation === void 0 ? void 0 : annotation.y) <= interval.end);
2996
- if (yMatch !== -1) {
2997
- if (annotations[yMatch] === undefined) {
2998
- annotations[yMatch] = {};
2999
- }
3000
- if ((annotation === null || annotation === void 0 ? void 0 : annotation.textangle) === 90) {
3001
- annotations[yMatch].yAnnotation = annotation.text;
3002
- } else {
3003
- annotations[yMatch].xAnnotation = annotation.text;
3004
- }
3005
- }
3006
- });
3007
- }
3008
- if (domainX.length > 0) {
3009
- const uniqueXIntervals = new Map();
3010
- domainX.forEach((interval)=>{
3011
- const key = `${interval.start}-${interval.end}`;
3012
- if (!uniqueXIntervals.has(key)) {
3013
- uniqueXIntervals.set(key, interval);
3014
- }
3015
- });
3016
- const sortedXStart = Array.from(uniqueXIntervals.values()).map((interval)=>interval.start).sort();
3017
- templateColumns = `repeat(${sortedXStart.length}, 1fr)`;
3018
- domainX.forEach((interval, index)=>{
3019
- const columnIndex = sortedXStart.findIndex((start)=>start === interval.start);
3020
- const columnNumber = columnIndex + 1; // Column numbers are 1-based
3021
- const annotationProps = annotations[index];
3022
- const xAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.xAnnotation;
3023
- const row = {
3024
- row: -1,
3025
- column: columnNumber,
3026
- xAnnotation,
3027
- xDomain: interval,
3028
- yDomain: {
3029
- start: 0,
3030
- end: 1
3031
- }
3032
- };
3033
- gridLayout[interval.cellName] = row;
3034
- });
3035
- }
3036
- if (domainY.length > 0) {
3037
- const uniqueYIntervals = new Map();
3038
- domainY.forEach((interval)=>{
3039
- const key = `${interval.start}-${interval.end}`;
3040
- if (!uniqueYIntervals.has(key)) {
3041
- uniqueYIntervals.set(key, interval);
3042
- }
3043
- });
3044
- const sortedYStart = Array.from(uniqueYIntervals.values()).map((interval)=>interval.start).sort();
3045
- const numberOfRows = sortedYStart.length;
3046
- templateRows = `repeat(${numberOfRows}, 1fr)`;
3047
- domainY.forEach((interval, index)=>{
3048
- const rowIndex = sortedYStart.findIndex((start)=>start === interval.start);
3049
- const rowNumber = numberOfRows - rowIndex; // Rows are 1-based and we need to reverse the order for CSS grid
3050
- const annotationProps = annotations[index];
3051
- const yAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.yAnnotation;
3052
- const cell = gridLayout[interval.cellName];
3053
- if (cell !== undefined) {
3054
- cell.row = rowNumber;
3055
- cell.yAnnotation = yAnnotation;
3056
- cell.yDomain = interval;
3057
- }
3058
- });
3059
- }
3060
- return {
3061
- templateRows,
3062
- templateColumns,
3063
- layout: gridLayout
3064
- };
3065
- };
3066
- /**
3067
- * @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/category_order_defaults.js#L50}
3068
- */ const getAxisCategoryOrderProps = (data, layout)=>{
3069
- const result = {};
3070
- const axesById = {
3071
- x: layout === null || layout === void 0 ? void 0 : layout.xaxis,
3072
- y: layout === null || layout === void 0 ? void 0 : layout.yaxis
3073
- };
3074
- Object.keys(axesById).forEach((axId)=>{
3075
- const ax = axesById[axId];
3076
- const axLetter = axId[0];
3077
- const propName = `${axLetter}AxisCategoryOrder`;
3078
- const values = [];
3079
- data.forEach((series)=>{
3080
- var _series_axLetter;
3081
- (_series_axLetter = series[axLetter]) === null || _series_axLetter === void 0 ? void 0 : _series_axLetter.forEach((val)=>{
3082
- if (!isInvalidValue(val)) {
3083
- values.push(val);
3084
- }
3085
- });
3086
- });
3087
- const isAxisTypeCategory = (ax === null || ax === void 0 ? void 0 : ax.type) === 'category' || isStringArray(values) && !isNumberArray(values) && !isDateArray(values);
3088
- if (!isAxisTypeCategory) {
3089
- result[propName] = 'data';
3090
- return;
3091
- }
3092
- const isValidArray = isArrayOrTypedArray(ax === null || ax === void 0 ? void 0 : ax.categoryarray) && ax.categoryarray.length > 0;
3093
- if (isValidArray && (!(ax === null || ax === void 0 ? void 0 : ax.categoryorder) || ax.categoryorder === 'array')) {
3094
- result[propName] = (ax === null || ax === void 0 ? void 0 : ax.autorange) === 'reversed' ? ax.categoryarray.slice().reverse() : ax.categoryarray;
3095
- return;
3096
- }
3097
- if (!(ax === null || ax === void 0 ? void 0 : ax.categoryorder) || ax.categoryorder === 'trace' || ax.categoryorder === 'array') {
3098
- const categoriesInTraceOrder = Array.from(new Set(values));
3099
- result[propName] = (ax === null || ax === void 0 ? void 0 : ax.autorange) === 'reversed' ? categoriesInTraceOrder.reverse() : categoriesInTraceOrder;
3100
- return;
3101
- }
3102
- result[propName] = ax.categoryorder;
3103
- });
3104
- return result;
3105
- };
3106
- const getBarProps = (data, layout, isHorizontal)=>{
3107
- let padding;
3108
- if (typeof (layout === null || layout === void 0 ? void 0 : layout.bargap) === 'number') {
3109
- if (layout.bargap >= 0 && layout.bargap <= 1) {
3110
- padding = layout.bargap;
3111
- } else {
3112
- // Plotly uses a default bargap of 0.2, as noted here: https://github.com/plotly/plotly.js/blob/1d5a249e43dd31ae50acf02117a19e5ac97387e9/src/traces/bar/layout_defaults.js#L58.
3113
- // However, we don't use this value as our default padding because it causes the bars to
3114
- // appear disproportionately wide in large containers.
3115
- padding = 0.2;
3116
- }
3117
- }
3118
- const plotlyBarWidths = data.map((series)=>{
3119
- if (series.type === 'bar' && (isArrayOrTypedArray(series.width) || typeof series.width === 'number')) {
3120
- return series.width;
3121
- }
3122
- return [];
3123
- }).flat();
3124
- const maxPlotlyBarWidth = d3Max(plotlyBarWidths);
3125
- if (typeof maxPlotlyBarWidth === 'number') {
3126
- padding = 1 - maxPlotlyBarWidth;
3127
- padding = Math.max(0, Math.min(padding, 1));
3128
- }
3129
- if (typeof padding === 'undefined') {
3130
- return {};
3131
- }
3132
- if (isHorizontal) {
3133
- return {
3134
- maxBarHeight: 1000,
3135
- yAxisPadding: padding
3136
- };
3137
- }
3138
- return {
3139
- barWidth: 'auto',
3140
- maxBarWidth: 1000,
3141
- xAxisInnerPadding: padding,
3142
- xAxisOuterPadding: padding / 2
3143
- };
3144
- };
3145
- const getAxisScaleTypeProps = (data, layout)=>{
3146
- var _axisObjects_x, _axisObjects_y, _axisObjects_y2;
3147
- const result = {};
3148
- const axisObjects = getAxisObjects(data, layout);
3149
- if (((_axisObjects_x = axisObjects.x) === null || _axisObjects_x === void 0 ? void 0 : _axisObjects_x.type) === 'log') {
3150
- result.xScaleType = 'log';
3151
- }
3152
- if (((_axisObjects_y = axisObjects.y) === null || _axisObjects_y === void 0 ? void 0 : _axisObjects_y.type) === 'log') {
3153
- result.yScaleType = 'log';
3154
- }
3155
- if (((_axisObjects_y2 = axisObjects.y2) === null || _axisObjects_y2 === void 0 ? void 0 : _axisObjects_y2.type) === 'log') {
3156
- result.secondaryYScaleType = 'log';
3157
- }
3158
- return result;
3159
- };
3160
- /**
3161
- * @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/tick_value_defaults.js#L8}
3162
- */ const getAxisTickProps = (data, layout)=>{
3163
- const props = {};
3164
- const axisObjects = getAxisObjects(data, layout);
3165
- Object.keys(axisObjects).forEach((axId)=>{
3166
- const ax = axisObjects[axId];
3167
- if (!ax) {
3168
- return;
3169
- }
3170
- const axType = getAxisType(data, ax);
3171
- if (axId === 'x' && axType === 'category') {
3172
- props.xAxis = {
3173
- tickLayout: 'auto'
3174
- };
3175
- }
3176
- if ((!ax.tickmode || ax.tickmode === 'array') && isArrayOrTypedArray(ax.tickvals)) {
3177
- const tickValues = axType === 'date' ? ax.tickvals.map((v)=>new Date(v)) : ax.tickvals;
3178
- if (axId === 'x') {
3179
- props.tickValues = tickValues;
3180
- props.xAxis = {
3181
- ...props.xAxis,
3182
- tickText: ax.ticktext
3183
- };
3184
- } else if (axId === 'y') {
3185
- props.yAxisTickValues = tickValues;
3186
- props.yAxis = {
3187
- ...props.yAxis,
3188
- tickText: ax.ticktext
3189
- };
3190
- }
3191
- return;
3192
- }
3193
- if ((!ax.tickmode || ax.tickmode === 'linear') && ax.dtick) {
3194
- const dtick = plotlyDtick(ax.dtick, axType);
3195
- const tick0 = plotlyTick0(ax.tick0, axType, dtick);
3196
- if (axId === 'x') {
3197
- props.xAxis = {
3198
- ...props.xAxis,
3199
- tickStep: dtick,
3200
- tick0
3201
- };
3202
- } else if (axId === 'y') {
3203
- props.yAxis = {
3204
- ...props.yAxis,
3205
- tickStep: dtick,
3206
- tick0
3207
- };
3208
- }
3209
- return;
3210
- }
3211
- if ((!ax.tickmode || ax.tickmode === 'auto') && typeof ax.nticks === 'number' && ax.nticks >= 0) {
3212
- if (axId === 'x') {
3213
- props.xAxisTickCount = ax.nticks;
3214
- } else if (axId === 'y') {
3215
- props.yAxisTickCount = ax.nticks;
3216
- }
3217
- }
3218
- });
3219
- return props;
3220
- };
3221
- /**
3222
- * @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/clean_ticks.js#L16}
3223
- */ const plotlyDtick = (dtick, axType)=>{
3224
- const isLogAx = axType === 'log';
3225
- const isDateAx = axType === 'date';
3226
- const isCatAx = axType === 'category';
3227
- const dtickDflt = isDateAx ? 86400000 : 1;
3228
- if (!dtick) {
3229
- return dtickDflt;
3230
- }
3231
- if (isNumber(dtick)) {
3232
- dtick = Number(dtick);
3233
- if (dtick <= 0) {
3234
- return dtickDflt;
3235
- }
3236
- if (isCatAx) {
3237
- // category dtick must be positive integers
3238
- return Math.max(1, Math.round(dtick));
3239
- }
3240
- if (isDateAx) {
3241
- // date dtick must be at least 0.1ms (our current precision)
3242
- return Math.max(0.1, dtick);
3243
- }
3244
- return dtick;
3245
- }
3246
- if (typeof dtick !== 'string' || !(isDateAx || isLogAx)) {
3247
- return dtickDflt;
3248
- }
3249
- const prefix = dtick.charAt(0);
3250
- const dtickNum = isNumber(dtick.slice(1)) ? Number(dtick.slice(1)) : 0;
3251
- if (dtickNum <= 0 || !// "M<n>" gives ticks every (integer) n months
3252
- (isDateAx && prefix === 'M' && dtickNum === Math.round(dtickNum) || // "L<f>" gives ticks linearly spaced in data (not in position) every (float) f
3253
- isLogAx && prefix === 'L' || // "D1" gives powers of 10 with all small digits between, "D2" gives only 2 and 5
3254
- isLogAx && prefix === 'D' && (dtickNum === 1 || dtickNum === 2))) {
3255
- return dtickDflt;
3256
- }
3257
- return dtick;
3258
- };
3259
- /**
3260
- * @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/clean_ticks.js#L70}
3261
- */ const plotlyTick0 = (tick0, axType, dtick)=>{
3262
- if (axType === 'date') {
3263
- return isDate(tick0) ? new Date(tick0) : new Date(DEFAULT_DATE_STRING);
3264
- }
3265
- if (dtick === 'D1' || dtick === 'D2') {
3266
- // D1 and D2 modes ignore tick0 entirely
3267
- return undefined;
3268
- }
3269
- // Aside from date axes, tick0 must be numeric
3270
- return isNumber(tick0) ? Number(tick0) : 0;
3271
- };
3272
- const getAxisObjects = (data, layout)=>{
3273
- // Traces are grouped by their xaxis property, and for each group/subplot, the adapter functions
3274
- // are called with the corresponding filtered data. As a result, all traces passed to an adapter
3275
- // function share the same xaxis.
3276
- let xAxisId;
3277
- const yAxisIds = new Set();
3278
- data.forEach((series)=>{
3279
- const axisIds = getAxisIds(series);
3280
- xAxisId = axisIds.x;
3281
- yAxisIds.add(axisIds.y);
3282
- });
3283
- const makeAxisObject = (axLetter, axId)=>({
3284
- ...layout === null || layout === void 0 ? void 0 : layout[getAxisKey(axLetter, axId)],
3285
- _id: `${axLetter}${axId > 1 ? axId : ''}`
3286
- });
3287
- const axisObjects = {};
3288
- if (typeof xAxisId === 'number') {
3289
- axisObjects.x = makeAxisObject('x', xAxisId);
3290
- }
3291
- const sortedYAxisIds = Array.from(yAxisIds).sort();
3292
- if (sortedYAxisIds.length > 0) {
3293
- axisObjects.y = makeAxisObject('y', sortedYAxisIds[0]);
3294
- }
3295
- if (sortedYAxisIds.length > 1) {
3296
- axisObjects.y2 = makeAxisObject('y', sortedYAxisIds[1]);
3297
- }
3298
- return axisObjects;
3299
- };
3300
- const getAxisType = (data, ax)=>{
3301
- if (!ax) {
3302
- return 'category';
3303
- }
3304
- var _ax_type;
3305
- if ([
3306
- 'linear',
3307
- 'log',
3308
- 'date',
3309
- 'category'
3310
- ].includes((_ax_type = ax.type) !== null && _ax_type !== void 0 ? _ax_type : '')) {
3311
- return ax.type;
3312
- }
3313
- const axLetter = ax._id[0];
3314
- const values = [];
3315
- data.forEach((series)=>{
3316
- const axId = series[`${axLetter}axis`];
3317
- if ((axId === ax._id || !axId && ax._id === axLetter) && isArrayOrTypedArray(series[axLetter])) {
3318
- series[axLetter].forEach((val)=>{
3319
- if (!isInvalidValue(val)) {
3320
- values.push(val);
3321
- }
3322
- });
3323
- }
3324
- });
3325
- if (isNumberArray(values) && !isYearArray(values)) {
3326
- return 'linear';
3327
- }
3328
- if (isDateArray(values)) {
3329
- return 'date';
3330
- }
3331
- return 'category';
3332
- };
3333
- const getAxisValueResolver = (axType, dateParser)=>{
3334
- const toDate = (value)=>{
3335
- const date = dateParser ? dateParser(value) : new Date(value);
3336
- return isNaN(date.getTime()) ? null : date;
3337
- };
3338
- return (value)=>{
3339
- if (isInvalidValue(value)) {
3340
- return null;
3341
- }
3342
- switch(axType){
3343
- case 'linear':
3344
- case 'log':
3345
- return isNumber(value) ? +value : null;
3346
- case 'date':
3347
- if (isNumber(value)) {
3348
- return toDate(+value);
3349
- }
3350
- if (typeof value === 'string') {
3351
- return toDate(value);
3352
- }
3353
- return null;
3354
- case 'category':
3355
- return `${value}`;
3356
- default:
3357
- return null;
3358
- }
3359
- };
3360
- };
3361
- /**
3362
- * This is experimental. Use it only with valid datetime strings to verify if they conform to the ISO 8601 format.
3363
- */ const isoDateRegex = /^\d{4}(-\d{2}(-\d{2})?)?(T\d{2}:\d{2}(:\d{2}(\.\d{1,9})?)?(Z)?)?$/;
3364
- /**
3365
- * We want to display localized date and time in the charts, so the useUTC prop is set to false.
3366
- * But this can sometimes cause the formatters to display the datetime incorrectly.
3367
- * To work around this issue, we use this function to adjust datetime strings so that they are always interpreted
3368
- * as local time, allowing the formatters to produce the correct output.
3369
- *
3370
- * FIXME: The formatters should always produce a clear and accurate localized output, regardless of the
3371
- * format used to create the date object.
3372
- */ const parseLocalDate = (value)=>{
3373
- if (typeof value === 'string') {
3374
- const match = value.match(isoDateRegex);
3375
- if (match) {
3376
- if (!match[3]) {
3377
- value += 'T00:00';
3378
- } else if (match[6]) {
3379
- value = value.replace('Z', '');
3380
- }
3381
- }
3382
- }
3383
- return new Date(value);
3384
- };
3385
- const POLAR_AXIS_BY_DATA_KEY = {
3386
- r: 'radialAxis',
3387
- theta: 'angularAxis'
3388
- };
3389
- export const DEFAULT_POLAR_SUBPLOT = 'polar';
3390
- const getPolarLayout = (trace, layout)=>{
3391
- const subplotId = (trace === null || trace === void 0 ? void 0 : trace.subplot) || DEFAULT_POLAR_SUBPLOT;
3392
- return layout === null || layout === void 0 ? void 0 : layout[subplotId];
3393
- };
3394
- const getValidAxisValues = (data, dataKey)=>{
3395
- const values = [];
3396
- data.forEach((series)=>{
3397
- if (isArrayOrTypedArray(series[dataKey])) {
3398
- series[dataKey].forEach((val)=>{
3399
- if (!isInvalidValue(val)) {
3400
- values.push(val);
3401
- }
3402
- });
3403
- }
3404
- });
3405
- return values;
3406
- };
3407
- const getPolarAxisType = (data, dataKey, declaredType)=>{
3408
- if ([
3409
- 'linear',
3410
- 'log',
3411
- 'date',
3412
- 'category'
3413
- ].includes(declaredType !== null && declaredType !== void 0 ? declaredType : '')) {
3414
- return declaredType;
3415
- }
3416
- const values = getValidAxisValues(data, dataKey);
3417
- if (isNumberArray(values) && !isYearArray(values)) {
3418
- return 'linear';
3419
- }
3420
- if (isDateArray(values)) {
3421
- return 'date';
3422
- }
3423
- return 'category';
3424
- };
3425
- const getPolarAxis = (data, dataKey, layout)=>{
3426
- const polarLayout = getPolarLayout(data[0], layout);
3427
- const ax = polarLayout === null || polarLayout === void 0 ? void 0 : polarLayout[POLAR_AXIS_BY_DATA_KEY[dataKey].toLowerCase()];
3428
- return {
3429
- ...ax,
3430
- _dataKey: dataKey,
3431
- _type: getPolarAxisType(data, dataKey, ax === null || ax === void 0 ? void 0 : ax.type)
3432
- };
3433
- };
3434
- const getPolarAxisTickProps = (data, ax)=>{
3435
- const props = {};
3436
- if ((!ax.tickmode || ax.tickmode === 'array') && isArrayOrTypedArray(ax.tickvals)) {
3437
- const tickValues = ax._type === 'date' ? ax.tickvals.map((v)=>new Date(v)) : ax.tickvals;
3438
- props.tickValues = tickValues;
3439
- props.tickText = ax.ticktext;
3440
- return props;
3441
- }
3442
- if ((!ax.tickmode || ax.tickmode === 'linear') && ax.dtick) {
3443
- const dtick = plotlyDtick(ax.dtick, ax._type);
3444
- const tick0 = plotlyTick0(ax.tick0, ax._type, dtick);
3445
- props.tickStep = dtick;
3446
- props.tick0 = tick0;
3447
- return props;
3448
- }
3449
- if ((!ax.tickmode || ax.tickmode === 'auto') && typeof ax.nticks === 'number' && ax.nticks >= 0) {
3450
- props.tickCount = ax.nticks;
3451
- }
3452
- return props;
3453
- };
3454
- const getPolarAxisCategoryOrder = (data, ax)=>{
3455
- if (ax._type !== 'category') {
3456
- return 'data';
3457
- }
3458
- const isValidArray = isArrayOrTypedArray(ax.categoryarray) && ax.categoryarray.length > 0;
3459
- if (isValidArray && (!ax.categoryorder || ax.categoryorder === 'array')) {
3460
- return ax.categoryarray;
3461
- }
3462
- if (!ax.categoryorder || ax.categoryorder === 'trace' || ax.categoryorder === 'array') {
3463
- const values = getValidAxisValues(data, ax._dataKey);
3464
- const categoriesInTraceOrder = Array.from(new Set(values));
3465
- return ax.autorange === 'reversed' ? categoriesInTraceOrder.reverse() : categoriesInTraceOrder;
3466
- }
3467
- return ax.categoryorder;
3468
- };
3469
- const getPolarAxisProps = (data, layout)=>{
3470
- const props = {};
3471
- Object.keys(POLAR_AXIS_BY_DATA_KEY).forEach((dataKey)=>{
3472
- const propName = POLAR_AXIS_BY_DATA_KEY[dataKey];
3473
- const ax = getPolarAxis(data, dataKey, layout);
3474
- props[propName] = {
3475
- scaleType: ax._type === 'log' ? 'log' : 'default',
3476
- categoryOrder: getPolarAxisCategoryOrder(data, ax),
3477
- tickFormat: ax.tickformat,
3478
- ...getPolarAxisTickProps(data, ax),
3479
- ...isArrayOrTypedArray(ax.range) ? {
3480
- rangeStart: ax.range[0],
3481
- rangeEnd: ax.range[1]
3482
- } : {}
3483
- };
3484
- if (propName === 'angularAxis') {
3485
- props[propName].unit = ax.thetaunit;
3486
- props.direction = ax.direction;
3487
- }
3488
- });
3489
- return props;
3490
- };