@fluentui/react-charts 9.0.1 → 9.0.3

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 (235) hide show
  1. package/CHANGELOG.md +58 -2
  2. package/dist/index.d.ts +1432 -238
  3. package/lib/AreaChart.js +1 -0
  4. package/lib/AreaChart.js.map +1 -0
  5. package/lib/GaugeChart.js +1 -0
  6. package/lib/GaugeChart.js.map +1 -0
  7. package/lib/GroupedVerticalBarChart.js +1 -0
  8. package/lib/GroupedVerticalBarChart.js.map +1 -0
  9. package/lib/HeatMapChart.js +1 -0
  10. package/lib/HeatMapChart.js.map +1 -0
  11. package/lib/HorizontalBarChartWithAxis.js +1 -0
  12. package/lib/HorizontalBarChartWithAxis.js.map +1 -0
  13. package/lib/SankeyChart.js +1 -0
  14. package/lib/SankeyChart.js.map +1 -0
  15. package/lib/ScatterChart.js +1 -0
  16. package/lib/ScatterChart.js.map +1 -0
  17. package/lib/VerticalStackedBarChart.js +1 -0
  18. package/lib/VerticalStackedBarChart.js.map +1 -0
  19. package/lib/components/AreaChart/AreaChart.js +775 -0
  20. package/lib/components/AreaChart/AreaChart.js.map +1 -0
  21. package/lib/components/AreaChart/AreaChart.types.js +4 -0
  22. package/lib/components/AreaChart/AreaChart.types.js.map +1 -0
  23. package/lib/components/AreaChart/index.js +3 -0
  24. package/lib/components/AreaChart/index.js.map +1 -0
  25. package/lib/components/AreaChart/useAreaChartStyles.styles.js +64 -0
  26. package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -0
  27. package/lib/components/CommonComponents/CartesianChart.js +30 -14
  28. package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
  29. package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
  30. package/lib/components/DeclarativeChart/DeclarativeChart.js +112 -65
  31. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  32. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +570 -159
  33. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  34. package/lib/components/DonutChart/Arc/Arc.js +1 -1
  35. package/lib/components/DonutChart/Arc/Arc.js.map +1 -1
  36. package/lib/components/DonutChart/DonutChart.js +1 -1
  37. package/lib/components/DonutChart/DonutChart.js.map +1 -1
  38. package/lib/components/GaugeChart/GaugeChart.js +592 -0
  39. package/lib/components/GaugeChart/GaugeChart.js.map +1 -0
  40. package/lib/components/GaugeChart/GaugeChart.types.js +4 -0
  41. package/lib/components/GaugeChart/GaugeChart.types.js.map +1 -0
  42. package/lib/components/GaugeChart/index.js +3 -0
  43. package/lib/components/GaugeChart/index.js.map +1 -0
  44. package/lib/components/GaugeChart/useGaugeChartStyles.styles.js +174 -0
  45. package/lib/components/GaugeChart/useGaugeChartStyles.styles.js.map +1 -0
  46. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +501 -0
  47. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -0
  48. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js +4 -0
  49. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js.map +1 -0
  50. package/lib/components/GroupedVerticalBarChart/index.js +3 -0
  51. package/lib/components/GroupedVerticalBarChart/index.js.map +1 -0
  52. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +90 -0
  53. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -0
  54. package/lib/components/HeatMapChart/HeatMapChart.js +588 -0
  55. package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -0
  56. package/lib/components/HeatMapChart/HeatMapChart.types.js +4 -0
  57. package/lib/components/HeatMapChart/HeatMapChart.types.js.map +1 -0
  58. package/lib/components/HeatMapChart/index.js +3 -0
  59. package/lib/components/HeatMapChart/index.js.map +1 -0
  60. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js +46 -0
  61. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -0
  62. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +571 -0
  63. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -0
  64. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js +4 -0
  65. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js.map +1 -0
  66. package/lib/components/HorizontalBarChartWithAxis/index.js +3 -0
  67. package/lib/components/HorizontalBarChartWithAxis/index.js.map +1 -0
  68. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +76 -0
  69. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -0
  70. package/lib/components/Legends/Legends.js +38 -37
  71. package/lib/components/Legends/Legends.js.map +1 -1
  72. package/lib/components/Legends/Legends.types.js.map +1 -1
  73. package/lib/components/LineChart/LineChart.js +43 -35
  74. package/lib/components/LineChart/LineChart.js.map +1 -1
  75. package/lib/components/SankeyChart/SankeyChart.js +1022 -0
  76. package/lib/components/SankeyChart/SankeyChart.js.map +1 -0
  77. package/lib/components/SankeyChart/SankeyChart.types.js +3 -0
  78. package/lib/components/SankeyChart/SankeyChart.types.js.map +1 -0
  79. package/lib/components/SankeyChart/index.js +3 -0
  80. package/lib/components/SankeyChart/index.js.map +1 -0
  81. package/lib/components/SankeyChart/useSankeyChartStyles.styles.js +109 -0
  82. package/lib/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -0
  83. package/lib/components/ScatterChart/ScatterChart.js +465 -0
  84. package/lib/components/ScatterChart/ScatterChart.js.map +1 -0
  85. package/lib/components/ScatterChart/ScatterChart.types.js +4 -0
  86. package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -0
  87. package/lib/components/ScatterChart/index.js +3 -0
  88. package/lib/components/ScatterChart/index.js.map +1 -0
  89. package/lib/components/ScatterChart/useScatterChartStyles.styles.js +65 -0
  90. package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -0
  91. package/lib/components/Sparkline/Sparkline.js.map +1 -1
  92. package/lib/components/VerticalBarChart/VerticalBarChart.js +165 -88
  93. package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  94. package/lib/components/VerticalBarChart/VerticalBarChart.types.js.map +1 -1
  95. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +904 -0
  96. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -0
  97. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js +1 -0
  98. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -0
  99. package/lib/components/VerticalStackedBarChart/index.js +3 -0
  100. package/lib/components/VerticalStackedBarChart/index.js.map +1 -0
  101. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +73 -0
  102. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -0
  103. package/lib/index.js +8 -0
  104. package/lib/index.js.map +1 -1
  105. package/lib/types/DataPoint.js +1 -3
  106. package/lib/types/DataPoint.js.map +1 -1
  107. package/lib/utilities/SVGTooltipText.js +49 -4
  108. package/lib/utilities/SVGTooltipText.js.map +1 -1
  109. package/lib/utilities/colors.js +20 -0
  110. package/lib/utilities/colors.js.map +1 -1
  111. package/lib/utilities/string.js +32 -0
  112. package/lib/utilities/string.js.map +1 -0
  113. package/lib/utilities/test-data.js +53 -0
  114. package/lib/utilities/test-data.js.map +1 -1
  115. package/lib/utilities/utilities.js +210 -20
  116. package/lib/utilities/utilities.js.map +1 -1
  117. package/lib-commonjs/AreaChart.js +6 -0
  118. package/lib-commonjs/AreaChart.js.map +1 -0
  119. package/lib-commonjs/GaugeChart.js +6 -0
  120. package/lib-commonjs/GaugeChart.js.map +1 -0
  121. package/lib-commonjs/GroupedVerticalBarChart.js +6 -0
  122. package/lib-commonjs/GroupedVerticalBarChart.js.map +1 -0
  123. package/lib-commonjs/HeatMapChart.js +6 -0
  124. package/lib-commonjs/HeatMapChart.js.map +1 -0
  125. package/lib-commonjs/HorizontalBarChartWithAxis.js +6 -0
  126. package/lib-commonjs/HorizontalBarChartWithAxis.js.map +1 -0
  127. package/lib-commonjs/SankeyChart.js +6 -0
  128. package/lib-commonjs/SankeyChart.js.map +1 -0
  129. package/lib-commonjs/ScatterChart.js +6 -0
  130. package/lib-commonjs/ScatterChart.js.map +1 -0
  131. package/lib-commonjs/VerticalStackedBarChart.js +6 -0
  132. package/lib-commonjs/VerticalStackedBarChart.js.map +1 -0
  133. package/lib-commonjs/components/AreaChart/AreaChart.js +781 -0
  134. package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -0
  135. package/lib-commonjs/components/AreaChart/AreaChart.types.js +7 -0
  136. package/lib-commonjs/components/AreaChart/AreaChart.types.js.map +1 -0
  137. package/lib-commonjs/components/AreaChart/index.js +8 -0
  138. package/lib-commonjs/components/AreaChart/index.js.map +1 -0
  139. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js +104 -0
  140. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -0
  141. package/lib-commonjs/components/CommonComponents/CartesianChart.js +29 -14
  142. package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
  143. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
  144. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +120 -73
  145. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  146. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +592 -178
  147. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  148. package/lib-commonjs/components/DonutChart/Arc/Arc.js +1 -1
  149. package/lib-commonjs/components/DonutChart/Arc/Arc.js.map +1 -1
  150. package/lib-commonjs/components/DonutChart/DonutChart.js +1 -1
  151. package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
  152. package/lib-commonjs/components/GaugeChart/GaugeChart.js +621 -0
  153. package/lib-commonjs/components/GaugeChart/GaugeChart.js.map +1 -0
  154. package/lib-commonjs/components/GaugeChart/GaugeChart.types.js +7 -0
  155. package/lib-commonjs/components/GaugeChart/GaugeChart.types.js.map +1 -0
  156. package/lib-commonjs/components/GaugeChart/index.js +8 -0
  157. package/lib-commonjs/components/GaugeChart/index.js.map +1 -0
  158. package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.js +252 -0
  159. package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.js.map +1 -0
  160. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +507 -0
  161. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -0
  162. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js +7 -0
  163. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js.map +1 -0
  164. package/lib-commonjs/components/GroupedVerticalBarChart/index.js +8 -0
  165. package/lib-commonjs/components/GroupedVerticalBarChart/index.js.map +1 -0
  166. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +139 -0
  167. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -0
  168. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +599 -0
  169. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -0
  170. package/lib-commonjs/components/HeatMapChart/HeatMapChart.types.js +7 -0
  171. package/lib-commonjs/components/HeatMapChart/HeatMapChart.types.js.map +1 -0
  172. package/lib-commonjs/components/HeatMapChart/index.js +8 -0
  173. package/lib-commonjs/components/HeatMapChart/index.js.map +1 -0
  174. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js +68 -0
  175. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -0
  176. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +580 -0
  177. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -0
  178. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js +7 -0
  179. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js.map +1 -0
  180. package/lib-commonjs/components/HorizontalBarChartWithAxis/index.js +8 -0
  181. package/lib-commonjs/components/HorizontalBarChartWithAxis/index.js.map +1 -0
  182. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +116 -0
  183. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -0
  184. package/lib-commonjs/components/Legends/Legends.js +37 -37
  185. package/lib-commonjs/components/Legends/Legends.js.map +1 -1
  186. package/lib-commonjs/components/Legends/Legends.types.js.map +1 -1
  187. package/lib-commonjs/components/LineChart/LineChart.js +41 -33
  188. package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
  189. package/lib-commonjs/components/SankeyChart/SankeyChart.js +1038 -0
  190. package/lib-commonjs/components/SankeyChart/SankeyChart.js.map +1 -0
  191. package/lib-commonjs/components/SankeyChart/SankeyChart.types.js +6 -0
  192. package/lib-commonjs/components/SankeyChart/SankeyChart.types.js.map +1 -0
  193. package/lib-commonjs/components/SankeyChart/index.js +8 -0
  194. package/lib-commonjs/components/SankeyChart/index.js.map +1 -0
  195. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js +179 -0
  196. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -0
  197. package/lib-commonjs/components/ScatterChart/ScatterChart.js +471 -0
  198. package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -0
  199. package/lib-commonjs/components/ScatterChart/ScatterChart.types.js +7 -0
  200. package/lib-commonjs/components/ScatterChart/ScatterChart.types.js.map +1 -0
  201. package/lib-commonjs/components/ScatterChart/index.js +8 -0
  202. package/lib-commonjs/components/ScatterChart/index.js.map +1 -0
  203. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js +96 -0
  204. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -0
  205. package/lib-commonjs/components/Sparkline/Sparkline.js.map +1 -1
  206. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +164 -87
  207. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  208. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.types.js.map +1 -1
  209. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +915 -0
  210. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -0
  211. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js +6 -0
  212. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -0
  213. package/lib-commonjs/components/VerticalStackedBarChart/index.js +8 -0
  214. package/lib-commonjs/components/VerticalStackedBarChart/index.js.map +1 -0
  215. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +120 -0
  216. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -0
  217. package/lib-commonjs/index.js +8 -0
  218. package/lib-commonjs/index.js.map +1 -1
  219. package/lib-commonjs/types/DataPoint.js +1 -3
  220. package/lib-commonjs/types/DataPoint.js.map +1 -1
  221. package/lib-commonjs/utilities/SVGTooltipText.js +49 -4
  222. package/lib-commonjs/utilities/SVGTooltipText.js.map +1 -1
  223. package/lib-commonjs/utilities/colors.js +23 -0
  224. package/lib-commonjs/utilities/colors.js.map +1 -1
  225. package/lib-commonjs/utilities/string.js +29 -0
  226. package/lib-commonjs/utilities/string.js.map +1 -0
  227. package/lib-commonjs/utilities/test-data.js +59 -0
  228. package/lib-commonjs/utilities/test-data.js.map +1 -1
  229. package/lib-commonjs/utilities/utilities.js +206 -19
  230. package/lib-commonjs/utilities/utilities.js.map +1 -1
  231. package/package.json +11 -8
  232. package/lib/components/DeclarativeChart/PlotlySchema.js +0 -7
  233. package/lib/components/DeclarativeChart/PlotlySchema.js.map +0 -1
  234. package/lib-commonjs/components/DeclarativeChart/PlotlySchema.js +0 -10
  235. package/lib-commonjs/components/DeclarativeChart/PlotlySchema.js.map +0 -1
@@ -9,32 +9,35 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
+ correctYearMonth: function() {
13
+ return correctYearMonth;
14
+ },
12
15
  findArrayAttributes: function() {
13
16
  return findArrayAttributes;
14
17
  },
15
18
  getColor: function() {
16
19
  return getColor;
17
20
  },
18
- isArrayOrTypedArray: function() {
19
- return isArrayOrTypedArray;
21
+ isMonthArray: function() {
22
+ return isMonthArray;
20
23
  },
21
- isDateArray: function() {
22
- return isDateArray;
24
+ transformPlotlyJsonToDonutProps: function() {
25
+ return transformPlotlyJsonToDonutProps;
23
26
  },
24
- isLineData: function() {
25
- return isLineData;
27
+ transformPlotlyJsonToGVBCProps: function() {
28
+ return transformPlotlyJsonToGVBCProps;
26
29
  },
27
- isMonthArray: function() {
28
- return isMonthArray;
30
+ transformPlotlyJsonToGaugeProps: function() {
31
+ return transformPlotlyJsonToGaugeProps;
29
32
  },
30
- isNumberArray: function() {
31
- return isNumberArray;
33
+ transformPlotlyJsonToHeatmapProps: function() {
34
+ return transformPlotlyJsonToHeatmapProps;
32
35
  },
33
- sanitizeJson: function() {
34
- return sanitizeJson;
36
+ transformPlotlyJsonToHorizontalBarWithAxisProps: function() {
37
+ return transformPlotlyJsonToHorizontalBarWithAxisProps;
35
38
  },
36
- transformPlotlyJsonToDonutProps: function() {
37
- return transformPlotlyJsonToDonutProps;
39
+ transformPlotlyJsonToSankeyProps: function() {
40
+ return transformPlotlyJsonToSankeyProps;
38
41
  },
39
42
  transformPlotlyJsonToScatterChartProps: function() {
40
43
  return transformPlotlyJsonToScatterChartProps;
@@ -42,27 +45,19 @@ _export(exports, {
42
45
  transformPlotlyJsonToVBCProps: function() {
43
46
  return transformPlotlyJsonToVBCProps;
44
47
  },
45
- updateXValues: function() {
46
- return updateXValues;
48
+ transformPlotlyJsonToVSBCProps: function() {
49
+ return transformPlotlyJsonToVSBCProps;
47
50
  }
48
51
  });
49
52
  const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
50
53
  const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
51
54
  const _d3array = require("d3-array");
52
55
  const _d3scale = require("d3-scale");
53
- const _d3format = require("d3-format");
54
56
  const _colors = require("../../utilities/colors");
55
57
  const _utilities = require("../../utilities/utilities");
58
+ const _chartutilities = require("@fluentui/chart-utilities");
56
59
  const _d3timeformat = require("d3-time-format");
57
- const SUPPORTED_PLOT_TYPES = [
58
- 'pie',
59
- 'bar',
60
- 'scatter',
61
- 'heatmap',
62
- 'sankey',
63
- 'indicator',
64
- 'histogram'
65
- ];
60
+ const _d3shape = require("d3-shape");
66
61
  const dashOptions = {
67
62
  dot: {
68
63
  strokeDasharray: '1, 5',
@@ -101,59 +96,13 @@ const dashOptions = {
101
96
  lineBorderWidth: '4'
102
97
  }
103
98
  };
104
- const isDate = (value)=>{
105
- const parsedDate = new Date(Date.parse(value));
106
- if (isNaN(parsedDate.getTime())) {
107
- return false;
108
- }
109
- const parsedYear = parsedDate.getFullYear();
110
- const yearInString = /\b\d{4}\b/.test(value);
111
- if (!yearInString && (parsedYear === 2000 || parsedYear === 2001)) {
112
- return false;
113
- }
114
- return true;
115
- };
116
- const isNumber = (value)=>!isNaN(parseFloat(value)) && isFinite(value);
117
99
  const isMonth = (possiblyMonthValue)=>{
118
100
  const parseFullMonth = (0, _d3timeformat.timeParse)('%B');
119
101
  const parseShortMonth = (0, _d3timeformat.timeParse)('%b');
120
102
  return parseFullMonth(possiblyMonthValue) !== null || parseShortMonth(possiblyMonthValue) !== null;
121
103
  };
122
- const isArrayOfType = (plotCoordinates, typeCheck, ...args)=>{
123
- if (!isArrayOrTypedArray(plotCoordinates)) {
124
- return false;
125
- }
126
- if (plotCoordinates.length === 0) {
127
- return false;
128
- }
129
- if (Array.isArray(plotCoordinates[0])) {
130
- // Handle 2D array
131
- return plotCoordinates.every((innerArray)=>innerArray.every((datum)=>typeCheck(datum, ...args)));
132
- } else {
133
- // Handle 1D array
134
- return plotCoordinates.every((datum)=>typeCheck(datum, ...args));
135
- }
136
- };
137
- const isDateArray = (data)=>{
138
- return isArrayOfType(data, isDate);
139
- };
140
- const isNumberArray = (data)=>{
141
- return isArrayOfType(data, isNumber);
142
- };
143
104
  const isMonthArray = (data)=>{
144
- return isArrayOfType(data, isMonth);
145
- };
146
- const isLineData = (data)=>{
147
- return !SUPPORTED_PLOT_TYPES.includes(`${data.type}`) && Array.isArray(data.x) && isArrayOfType(data.y, (value)=>typeof value === 'number') && data.x.length > 0 && data.x.length === data.y.length;
148
- };
149
- const invalidate2Dseries = (series, chartType)=>{
150
- var _series_x, _series_y;
151
- if (((_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x.length) > 0 && Array.isArray(series.x[0])) {
152
- throw new Error(`transform to ${chartType}:: 2D x array not supported`);
153
- }
154
- if (((_series_y = series.y) === null || _series_y === void 0 ? void 0 : _series_y.length) > 0 && Array.isArray(series.y[0])) {
155
- throw new Error(`transform to ${chartType}:: 2D y array not supported`);
156
- }
105
+ return (0, _chartutilities.isArrayOfType)(data, isMonth);
157
106
  };
158
107
  const getLegend = (series, index)=>{
159
108
  return series.name || `Series ${index + 1}`;
@@ -168,14 +117,14 @@ function getTitles(layout) {
168
117
  };
169
118
  return titles;
170
119
  }
171
- const updateXValues = (xValues)=>{
120
+ const correctYearMonth = (xValues)=>{
172
121
  const presentYear = new Date().getFullYear();
173
122
  if (xValues.length > 0 && Array.isArray(xValues[0])) {
174
123
  throw new Error('updateXValues:: 2D array not supported');
175
124
  }
176
125
  const dates = xValues.map((possiblyMonthValue)=>{
177
126
  const parsedDate = `${possiblyMonthValue} 01, ${presentYear}`;
178
- return isDate(parsedDate) ? new Date(parsedDate) : null;
127
+ return (0, _chartutilities.isDate)(parsedDate) ? new Date(parsedDate) : null;
179
128
  });
180
129
  for(let i = dates.length - 1; i > 0; i--){
181
130
  const currentMonth = dates[i].getMonth();
@@ -226,16 +175,23 @@ const getSecondaryYAxisValues = (series, layout)=>{
226
175
  return secondaryYAxisValues;
227
176
  };
228
177
  const transformPlotlyJsonToDonutProps = (input, colorMap, isDarkTheme)=>{
229
- var _firstData_labels, _input_layout, _input_layout1, _input_layout2;
178
+ var _firstData_labels, _input_layout, _input_layout1, _input_layout2, _input_layout3;
230
179
  const firstData = input.data[0];
231
- const donutData = (_firstData_labels = firstData.labels) === null || _firstData_labels === void 0 ? void 0 : _firstData_labels.map((label, index)=>{
180
+ const mapLegendToDataPoint = {};
181
+ (_firstData_labels = firstData.labels) === null || _firstData_labels === void 0 ? void 0 : _firstData_labels.forEach((label, index)=>{
232
182
  var _firstData_values;
233
183
  const color = getColor(label, colorMap, isDarkTheme);
234
- return {
235
- legend: label,
236
- data: (_firstData_values = firstData.values) === null || _firstData_values === void 0 ? void 0 : _firstData_values[index],
237
- color
238
- };
184
+ //ToDo how to handle string data?
185
+ const value = typeof ((_firstData_values = firstData.values) === null || _firstData_values === void 0 ? void 0 : _firstData_values[index]) === 'number' ? firstData.values[index] : 1;
186
+ if (!mapLegendToDataPoint[label]) {
187
+ mapLegendToDataPoint[label] = {
188
+ legend: label,
189
+ data: value,
190
+ color
191
+ };
192
+ } else {
193
+ mapLegendToDataPoint[label].data += value;
194
+ }
239
195
  });
240
196
  var _input_layout_width;
241
197
  const width = (_input_layout_width = (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width) !== null && _input_layout_width !== void 0 ? _input_layout_width : 440;
@@ -253,10 +209,10 @@ const transformPlotlyJsonToDonutProps = (input, colorMap, isDarkTheme)=>{
253
209
  return {
254
210
  data: {
255
211
  chartTitle,
256
- chartData: donutData
212
+ chartData: Object.values(mapLegendToDataPoint)
257
213
  },
258
214
  hideLegend: ((_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.showlegend) === false ? true : false,
259
- width,
215
+ width: (_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : _input_layout3.width,
260
216
  height,
261
217
  innerRadius,
262
218
  hideLabels,
@@ -266,106 +222,194 @@ const transformPlotlyJsonToDonutProps = (input, colorMap, isDarkTheme)=>{
266
222
  ].includes(firstData.textinfo) : true
267
223
  };
268
224
  };
225
+ const transformPlotlyJsonToVSBCProps = (input, colorMap, isDarkTheme, fallbackVSBC)=>{
226
+ var _input_layout, _input_layout1;
227
+ const mapXToDataPoints = {};
228
+ let yMaxValue = 0;
229
+ let secondaryYAxisValues = {};
230
+ input.data.forEach((series, index1)=>{
231
+ var _series_x;
232
+ (_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x.forEach((x, index2)=>{
233
+ var _series_y;
234
+ if (!mapXToDataPoints[x]) {
235
+ mapXToDataPoints[x] = {
236
+ xAxisPoint: x,
237
+ chartData: [],
238
+ lineData: []
239
+ };
240
+ }
241
+ const legend = getLegend(series, index1);
242
+ var _series_y_index2;
243
+ const yVal = (_series_y_index2 = (_series_y = series.y) === null || _series_y === void 0 ? void 0 : _series_y[index2]) !== null && _series_y_index2 !== void 0 ? _series_y_index2 : 0;
244
+ if (series.type === 'bar') {
245
+ const color = getColor(legend, colorMap, isDarkTheme);
246
+ mapXToDataPoints[x].chartData.push({
247
+ legend,
248
+ data: yVal,
249
+ color
250
+ });
251
+ } else if (series.type === 'scatter' || (0, _chartutilities.isLineData)(series) || !!fallbackVSBC) {
252
+ const color = getColor(legend, colorMap, isDarkTheme);
253
+ const lineOptions = getLineOptions(series.line);
254
+ mapXToDataPoints[x].lineData.push({
255
+ legend,
256
+ y: yVal,
257
+ color,
258
+ ...lineOptions ? {
259
+ lineOptions
260
+ } : {}
261
+ });
262
+ }
263
+ yMaxValue = Math.max(yMaxValue, yVal);
264
+ });
265
+ secondaryYAxisValues = getSecondaryYAxisValues(series, input.layout);
266
+ });
267
+ const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
268
+ var _input_layout_height;
269
+ return {
270
+ data: Object.values(mapXToDataPoints),
271
+ width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
272
+ 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,
273
+ barWidth: 'auto',
274
+ yMaxValue,
275
+ chartTitle,
276
+ xAxisTitle,
277
+ yAxisTitle,
278
+ mode: 'plotly',
279
+ secondaryYAxistitle: secondaryYAxisValues.secondaryYAxistitle,
280
+ secondaryYScaleOptions: secondaryYAxisValues.secondaryYScaleOptions,
281
+ hideTickOverlap: true
282
+ };
283
+ };
284
+ const transformPlotlyJsonToGVBCProps = (input, colorMap, isDarkTheme)=>{
285
+ var _input_layout, _input_layout1;
286
+ const mapXToDataPoints = {};
287
+ let secondaryYAxisValues = {};
288
+ input.data.forEach((series, index1)=>{
289
+ var _series_x;
290
+ (_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x.forEach((x, index2)=>{
291
+ if (!mapXToDataPoints[x]) {
292
+ mapXToDataPoints[x] = {
293
+ name: x.toString(),
294
+ series: []
295
+ };
296
+ }
297
+ if (series.type === 'bar') {
298
+ var _series_y;
299
+ const legend = getLegend(series, index1);
300
+ const color = getColor(legend, colorMap, isDarkTheme);
301
+ var _series_y_index2;
302
+ mapXToDataPoints[x].series.push({
303
+ key: legend,
304
+ data: (_series_y_index2 = (_series_y = series.y) === null || _series_y === void 0 ? void 0 : _series_y[index2]) !== null && _series_y_index2 !== void 0 ? _series_y_index2 : 0,
305
+ xAxisCalloutData: x,
306
+ color,
307
+ legend
308
+ });
309
+ }
310
+ });
311
+ secondaryYAxisValues = getSecondaryYAxisValues(series, input.layout);
312
+ });
313
+ const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
314
+ var _input_layout_height;
315
+ return {
316
+ data: Object.values(mapXToDataPoints),
317
+ width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
318
+ 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,
319
+ barWidth: 'auto',
320
+ chartTitle,
321
+ xAxisTitle,
322
+ yAxisTitle,
323
+ mode: 'plotly',
324
+ secondaryYAxistitle: secondaryYAxisValues.secondaryYAxistitle,
325
+ secondaryYScaleOptions: secondaryYAxisValues.secondaryYScaleOptions,
326
+ hideTickOverlap: true
327
+ };
328
+ };
269
329
  const transformPlotlyJsonToVBCProps = (input, colorMap, isDarkTheme)=>{
330
+ var _input_layout, _input_layout1;
270
331
  const vbcData = [];
271
- input.data.forEach((series, index)=>{
332
+ input.data.forEach((series, seriesIdx)=>{
272
333
  var _series_xbins, _series_xbins1, _series_xbins2;
273
- invalidate2Dseries(series, 'VBC');
274
334
  if (!series.x) {
275
335
  return;
276
336
  }
277
- const scale = (0, _d3scale.scaleLinear)().domain((0, _d3array.extent)(series.x)).nice();
278
- let [xMin, xMax] = scale.domain();
279
- xMin = typeof ((_series_xbins = series.xbins) === null || _series_xbins === void 0 ? void 0 : _series_xbins.start) === 'number' ? series.xbins.start : xMin;
280
- xMax = typeof ((_series_xbins1 = series.xbins) === null || _series_xbins1 === void 0 ? void 0 : _series_xbins1.end) === 'number' ? series.xbins.end : xMax;
281
- const bin = (0, _d3array.bin)().domain([
282
- xMin,
283
- xMax
284
- ]);
285
- if (typeof ((_series_xbins2 = series.xbins) === null || _series_xbins2 === void 0 ? void 0 : _series_xbins2.size) === 'number') {
286
- const thresholds = [];
287
- let th = xMin;
288
- const precision = (0, _d3format.precisionFixed)(series.xbins.size);
289
- const format = (0, _d3format.format)(`.${precision}f`);
290
- while(th < xMax + series.xbins.size){
291
- thresholds.push(parseFloat(format(th)));
292
- th += series.xbins.size;
337
+ const isXString = isStringArray(series.x);
338
+ const xBins = createBins(series.x, (_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);
339
+ const yBins = xBins.map(()=>[]);
340
+ let total = 0;
341
+ series.x.forEach((xVal, index)=>{
342
+ const binIdx = findBinIndex(xBins, xVal, isXString);
343
+ if (binIdx !== -1) {
344
+ var _series_y;
345
+ var _series_y_index;
346
+ yBins[binIdx].push((_series_y_index = (_series_y = series.y) === null || _series_y === void 0 ? void 0 : _series_y[index]) !== null && _series_y_index !== void 0 ? _series_y_index : 1);
293
347
  }
294
- xMin = thresholds[0];
295
- xMax = thresholds[thresholds.length - 1];
296
- bin.domain([
297
- xMin,
298
- xMax
299
- ]).thresholds(thresholds);
300
- }
301
- const buckets = bin(series.x);
302
- // If the start or end of xbins is specified, then the number of datapoints may become less than x.length
303
- const totalDataPoints = (0, _d3array.merge)(buckets).length;
304
- buckets.forEach((bucket)=>{
305
- const legend = getLegend(series, index);
348
+ });
349
+ const y = yBins.map((bin)=>{
350
+ const yVal = calculateHistFunc(series.histfunc, bin);
351
+ total += yVal;
352
+ return yVal;
353
+ });
354
+ xBins.forEach((bin, index)=>{
355
+ const legend = getLegend(series, seriesIdx);
306
356
  const color = getColor(legend, colorMap, isDarkTheme);
307
- let y = bucket.length;
308
- if (series.histnorm === 'percent') {
309
- y = bucket.length / totalDataPoints * 100;
310
- } else if (series.histnorm === 'probability') {
311
- y = bucket.length / totalDataPoints;
312
- } else if (series.histnorm === 'density') {
313
- y = bucket.x0 === bucket.x1 ? 0 : bucket.length / (bucket.x1 - bucket.x0);
314
- } else if (series.histnorm === 'probability density') {
315
- y = bucket.x0 === bucket.x1 ? 0 : bucket.length / (totalDataPoints * (bucket.x1 - bucket.x0));
316
- } else if (series.histfunc === 'sum') {
317
- y = (0, _d3array.sum)(bucket);
318
- } else if (series.histfunc === 'avg') {
319
- y = bucket.length === 0 ? 0 : (0, _d3array.sum)(bucket) / bucket.length;
320
- } else if (series.histfunc === 'min') {
321
- y = (0, _d3array.min)(bucket);
322
- } else if (series.histfunc === 'max') {
323
- y = (0, _d3array.max)(bucket);
324
- }
357
+ const yVal = calculateHistNorm(series.histnorm, y[index], total, isXString ? bin.length : getBinSize(bin));
325
358
  vbcData.push({
326
- x: (bucket.x1 + bucket.x0) / 2,
327
- y,
359
+ x: isXString ? bin.join(', ') : getBinCenter(bin),
360
+ y: yVal,
328
361
  legend,
329
362
  color,
330
- xAxisCalloutData: `[${bucket.x0} - ${bucket.x1})`
363
+ ...isXString ? {} : {
364
+ xAxisCalloutData: `[${bin.x0} - ${bin.x1})`
365
+ }
331
366
  });
332
367
  });
333
368
  });
334
369
  const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
370
+ var _input_layout_height;
335
371
  return {
336
372
  data: vbcData,
337
- // width: layout?.width,
338
- // height: layout?.height,
373
+ width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
374
+ 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,
339
375
  chartTitle,
340
376
  xAxisTitle,
341
377
  yAxisTitle,
378
+ mode: 'plotly',
342
379
  hideTickOverlap: true
343
380
  };
344
381
  };
345
382
  const transformPlotlyJsonToScatterChartProps = (input, isAreaChart, colorMap, isDarkTheme)=>{
346
383
  let secondaryYAxisValues = {};
384
+ let mode = 'tonexty';
347
385
  const chartData = input.data.map((series, index)=>{
348
- var _series_line;
349
- invalidate2Dseries(series, 'Scatter');
350
386
  const xValues = series.x;
351
387
  const isString = typeof xValues[0] === 'string';
352
- const isXDate = isDateArray(xValues);
353
- const isXNumber = isNumberArray(xValues);
388
+ const isXDate = (0, _chartutilities.isDateArray)(xValues);
389
+ const isXNumber = (0, _chartutilities.isNumberArray)(xValues);
354
390
  const legend = getLegend(series, index);
355
391
  const lineColor = getColor(legend, colorMap, isDarkTheme);
356
392
  secondaryYAxisValues = getSecondaryYAxisValues(series, input.layout);
393
+ mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
394
+ const lineOptions = getLineOptions(series.line);
357
395
  return {
358
396
  legend,
359
- ...((_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.dash) && dashOptions[series.line.dash] ? {
360
- lineOptions: {
361
- ...dashOptions[series.line.dash]
362
- }
363
- } : {},
364
- data: xValues.map((x, i)=>({
397
+ data: xValues.map((x, i)=>{
398
+ var _series_marker, _series_marker1;
399
+ return {
365
400
  x: isString ? isXDate ? new Date(x) : isXNumber ? parseFloat(x) : x : x,
366
- y: series.y[i]
367
- })),
368
- color: lineColor
401
+ y: series.y[i],
402
+ ...Array.isArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.size) ? {
403
+ markerSize: series.marker.size[i]
404
+ } : typeof ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.size) === 'number' ? {
405
+ markerSize: series.marker.size
406
+ } : {}
407
+ };
408
+ }),
409
+ color: lineColor,
410
+ ...lineOptions ? {
411
+ lineOptions
412
+ } : {}
369
413
  };
370
414
  });
371
415
  const yMinMaxValues = (0, _utilities.findNumericMinMaxOfY)(chartData);
@@ -374,43 +418,296 @@ const transformPlotlyJsonToScatterChartProps = (input, isAreaChart, colorMap, is
374
418
  chartTitle,
375
419
  lineChartData: chartData
376
420
  };
421
+ if (isAreaChart) {
422
+ var _input_layout, _input_layout1;
423
+ var _input_layout_height;
424
+ return {
425
+ data: chartProps,
426
+ supportNegativeData: true,
427
+ xAxisTitle,
428
+ yAxisTitle,
429
+ secondaryYAxistitle: secondaryYAxisValues.secondaryYAxistitle,
430
+ secondaryYScaleOptions: secondaryYAxisValues.secondaryYScaleOptions,
431
+ mode,
432
+ width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
433
+ 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,
434
+ hideTickOverlap: true
435
+ };
436
+ } else {
437
+ var _input_layout2, _input_layout3;
438
+ var _input_layout_height1;
439
+ return {
440
+ data: chartProps,
441
+ supportNegativeData: true,
442
+ xAxisTitle,
443
+ yAxisTitle,
444
+ secondaryYAxistitle: secondaryYAxisValues.secondaryYAxistitle,
445
+ secondaryYScaleOptions: secondaryYAxisValues.secondaryYScaleOptions,
446
+ roundedTicks: true,
447
+ yMinValue: yMinMaxValues.startValue,
448
+ yMaxValue: yMinMaxValues.endValue,
449
+ width: (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.width,
450
+ height: (_input_layout_height1 = (_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : _input_layout3.height) !== null && _input_layout_height1 !== void 0 ? _input_layout_height1 : 350,
451
+ hideTickOverlap: true,
452
+ enableReflow: false
453
+ };
454
+ }
455
+ };
456
+ const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, colorMap, isDarkTheme)=>{
457
+ 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;
458
+ const chartData = input.data.map((series, index)=>{
459
+ return series.y.map((yValue, i)=>{
460
+ const color = getColor(yValue, colorMap, isDarkTheme);
461
+ return {
462
+ x: series.x[i],
463
+ y: yValue,
464
+ legend: yValue,
465
+ color
466
+ };
467
+ });
468
+ }).flat() //reversing the order to invert the Y bars order as required by plotly.
469
+ .reverse();
470
+ var _input_layout_height;
471
+ 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;
472
+ var _input_layout_margin_l;
473
+ 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;
474
+ var _input_layout_margin_pad;
475
+ 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;
476
+ const availableHeight = chartHeight - margin - padding;
477
+ const numberOfBars = input.data[0].y.length;
478
+ const scalingFactor = 0.01;
479
+ const gapFactor = 1 / (1 + scalingFactor * numberOfBars);
480
+ const barHeight = availableHeight / (numberOfBars * (1 + gapFactor));
481
+ const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
377
482
  return {
378
- data: chartProps,
379
- supportNegativeData: true,
483
+ data: chartData,
484
+ chartTitle,
380
485
  xAxisTitle,
381
486
  yAxisTitle,
382
- secondaryYAxistitle: secondaryYAxisValues.secondaryYAxistitle,
383
- secondaryYScaleOptions: secondaryYAxisValues.secondaryYScaleOptions,
384
- roundedTicks: true,
385
- yMinValue: yMinMaxValues.startValue,
386
- yMaxValue: yMinMaxValues.endValue,
487
+ 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) || '',
488
+ barHeight,
489
+ showYAxisLables: true,
490
+ height: chartHeight,
491
+ width: (_input_layout6 = input.layout) === null || _input_layout6 === void 0 ? void 0 : _input_layout6.width,
387
492
  hideTickOverlap: true
388
493
  };
389
494
  };
390
- const MAX_DEPTH = 15;
391
- const sanitizeJson = (jsonObject, depth = 0)=>{
392
- if (depth > MAX_DEPTH) {
393
- throw new Error('Maximum json depth exceeded');
394
- }
395
- if (typeof jsonObject === 'object' && jsonObject !== null) {
396
- for(const key in jsonObject){
397
- if (jsonObject.hasOwnProperty(key)) {
398
- if (typeof jsonObject[key] === 'string') {
399
- jsonObject[key] = jsonObject[key].replace(/</g, '&lt;').replace(/>/g, '&gt;');
400
- } else {
401
- jsonObject[key] = sanitizeJson(jsonObject[key], depth + 1);
402
- }
495
+ const transformPlotlyJsonToHeatmapProps = (input)=>{
496
+ var _input_layout, _input_layout1;
497
+ const firstData = input.data[0];
498
+ const heatmapDataPoints = [];
499
+ let zMin = Number.POSITIVE_INFINITY;
500
+ let zMax = Number.NEGATIVE_INFINITY;
501
+ if (firstData.type === 'histogram2d') {
502
+ var _firstData_xbins, _firstData_xbins1, _firstData_xbins2, _firstData_ybins, _firstData_ybins1, _firstData_ybins2, _firstData_x;
503
+ const isXString = isStringArray(firstData.x);
504
+ const isYString = isStringArray(firstData.y);
505
+ const xBins = createBins(firstData.x, (_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);
506
+ const yBins = createBins(firstData.y, (_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);
507
+ const zBins = yBins.map(()=>xBins.map(()=>[]));
508
+ let total = 0;
509
+ (_firstData_x = firstData.x) === null || _firstData_x === void 0 ? void 0 : _firstData_x.forEach((xVal, index)=>{
510
+ var _firstData_y;
511
+ const xBinIdx = findBinIndex(xBins, xVal, isXString);
512
+ const yBinIdx = findBinIndex(yBins, (_firstData_y = firstData.y) === null || _firstData_y === void 0 ? void 0 : _firstData_y[index], isYString);
513
+ if (xBinIdx !== -1 && yBinIdx !== -1) {
514
+ var _firstData_z;
515
+ var _firstData_z_index;
516
+ zBins[yBinIdx][xBinIdx].push((_firstData_z_index = (_firstData_z = firstData.z) === null || _firstData_z === void 0 ? void 0 : _firstData_z[index]) !== null && _firstData_z_index !== void 0 ? _firstData_z_index : 1);
403
517
  }
518
+ });
519
+ const z = zBins.map((row)=>{
520
+ return row.map((bin)=>{
521
+ const zVal = calculateHistFunc(firstData.histfunc, bin);
522
+ total += zVal;
523
+ return zVal;
524
+ });
525
+ });
526
+ xBins.forEach((xBin, xIdx)=>{
527
+ yBins.forEach((yBin, yIdx)=>{
528
+ const zVal = calculateHistNorm(firstData.histnorm, z[yIdx][xIdx], total, isXString ? xBin.length : getBinSize(xBin), isYString ? yBin.length : getBinSize(yBin));
529
+ heatmapDataPoints.push({
530
+ x: isXString ? xBin.join(', ') : getBinCenter(xBin),
531
+ y: isYString ? yBin.join(', ') : getBinCenter(yBin),
532
+ value: zVal,
533
+ rectText: zVal
534
+ });
535
+ if (typeof zVal === 'number') {
536
+ zMin = Math.min(zMin, zVal);
537
+ zMax = Math.max(zMax, zVal);
538
+ }
539
+ });
540
+ });
541
+ } else {
542
+ var _firstData_x1;
543
+ (_firstData_x1 = firstData.x) === null || _firstData_x1 === void 0 ? void 0 : _firstData_x1.forEach((xVal, xIdx)=>{
544
+ var _firstData_y;
545
+ (_firstData_y = firstData.y) === null || _firstData_y === void 0 ? void 0 : _firstData_y.forEach((yVal, yIdx)=>{
546
+ var _firstData_z_yIdx, _firstData_z, _input_layout_xaxis, _input_layout, _input_layout_yaxis, _input_layout1;
547
+ const zVal = (_firstData_z = firstData.z) === null || _firstData_z === void 0 ? void 0 : (_firstData_z_yIdx = _firstData_z[yIdx]) === null || _firstData_z_yIdx === void 0 ? void 0 : _firstData_z_yIdx[xIdx];
548
+ heatmapDataPoints.push({
549
+ 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,
550
+ 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,
551
+ value: zVal,
552
+ rectText: zVal
553
+ });
554
+ if (typeof zVal === 'number') {
555
+ zMin = Math.min(zMin, zVal);
556
+ zMax = Math.max(zMax, zVal);
557
+ }
558
+ });
559
+ });
560
+ }
561
+ var _firstData_name;
562
+ const heatmapData = {
563
+ legend: (_firstData_name = firstData.name) !== null && _firstData_name !== void 0 ? _firstData_name : '',
564
+ data: heatmapDataPoints,
565
+ value: 0
566
+ };
567
+ // Initialize domain and range to default values
568
+ const defaultDomain = [
569
+ zMin,
570
+ (zMax + zMin) / 2,
571
+ zMax
572
+ ];
573
+ const defaultRange = [
574
+ (0, _colors.getColorFromToken)(_colors.DataVizPalette.color1),
575
+ (0, _colors.getColorFromToken)(_colors.DataVizPalette.color2),
576
+ (0, _colors.getColorFromToken)(_colors.DataVizPalette.color3)
577
+ ];
578
+ const domainValuesForColorScale = Array.isArray(firstData.colorscale) ? firstData.colorscale.map((arr)=>arr[0] * (zMax - zMin) + zMin) : defaultDomain;
579
+ const rangeValuesForColorScale = Array.isArray(firstData.colorscale) ? firstData.colorscale.map((arr)=>arr[1]) : defaultRange;
580
+ const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
581
+ var _input_layout_height;
582
+ return {
583
+ data: [
584
+ heatmapData
585
+ ],
586
+ domainValuesForColorScale,
587
+ rangeValuesForColorScale,
588
+ hideLegend: true,
589
+ showYAxisLables: true,
590
+ chartTitle,
591
+ xAxisTitle,
592
+ yAxisTitle,
593
+ sortOrder: 'none',
594
+ width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
595
+ 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,
596
+ hideTickOverlap: true
597
+ };
598
+ };
599
+ const transformPlotlyJsonToSankeyProps = (input, colorMap, isDarkTheme)=>{
600
+ var _node_label, _input_layout, _input_layout1;
601
+ const { link, node } = input.data[0];
602
+ var _link_value;
603
+ const validLinks = ((_link_value = link === null || link === void 0 ? void 0 : link.value) !== null && _link_value !== void 0 ? _link_value : []).map((val, index)=>({
604
+ value: val,
605
+ source: link === null || link === void 0 ? void 0 : link.source[index],
606
+ target: link === null || link === void 0 ? void 0 : link.target[index]
607
+ })) // eslint-disable-next-line @typescript-eslint/no-shadow
608
+ // Filter out negative nodes, unequal nodes and self-references (circular links)
609
+ .filter((x)=>x.source >= 0 && x.target >= 0 && x.source !== x.target);
610
+ const sankeyChartData = {
611
+ nodes: (_node_label = node.label) === null || _node_label === void 0 ? void 0 : _node_label.map((label, index)=>{
612
+ const color = getColor(label, colorMap, isDarkTheme);
613
+ return {
614
+ nodeId: index,
615
+ name: label,
616
+ color
617
+ };
618
+ }),
619
+ links: validLinks.map((validLink, index)=>{
620
+ return {
621
+ ...validLink
622
+ };
623
+ })
624
+ };
625
+ // const styles: SankeyChartProps['styles'] = {
626
+ // root: {
627
+ // ...(input.layout?.font?.size ? { fontSize: input.layout.font?.size } : {}),
628
+ // },
629
+ // };
630
+ const { chartTitle } = getTitles(input.layout);
631
+ var _input_layout_height;
632
+ return {
633
+ data: {
634
+ chartTitle,
635
+ SankeyChartData: sankeyChartData
636
+ },
637
+ width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
638
+ 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 : 468,
639
+ // TODO
640
+ // styles,
641
+ enableReflow: true
642
+ };
643
+ };
644
+ const transformPlotlyJsonToGaugeProps = (input, colorMap, isDarkTheme)=>{
645
+ var _firstData_gauge_steps, _firstData_gauge, _firstData_gauge_axis_range, _firstData_gauge_axis, _firstData_gauge1, _firstData_gauge_axis_range1, _firstData_gauge_axis1, _firstData_gauge2, _firstData_delta, _firstData_gauge_axis_range2, _firstData_gauge_axis2, _firstData_gauge3, _firstData_gauge_axis_range3, _firstData_gauge_axis3, _firstData_gauge4, _firstData_gauge_axis_range4, _firstData_gauge_axis4, _firstData_gauge5, _firstData_gauge_axis_range5, _firstData_gauge_axis5, _firstData_gauge6, _firstData_gauge_steps1, _firstData_gauge7;
646
+ const firstData = input.data[0];
647
+ var _firstData_gauge_axis_range_, _firstData_value, _firstData_gauge_axis_range_1, _firstData_value1;
648
+ const segments = ((_firstData_gauge = firstData.gauge) === null || _firstData_gauge === void 0 ? void 0 : (_firstData_gauge_steps = _firstData_gauge.steps) === null || _firstData_gauge_steps === void 0 ? void 0 : _firstData_gauge_steps.length) ? firstData.gauge.steps.map((step, index)=>{
649
+ var _step_range, _step_range1;
650
+ const legend = step.name || `Segment ${index + 1}`;
651
+ const color = getColor(legend, colorMap, isDarkTheme);
652
+ return {
653
+ legend,
654
+ 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]),
655
+ color
656
+ };
657
+ }) : [
658
+ {
659
+ legend: 'Current',
660
+ size: (_firstData_value = firstData.value) !== null && _firstData_value !== void 0 ? _firstData_value : 0 - ((_firstData_gauge_axis_range_ = (_firstData_gauge1 = firstData.gauge) === null || _firstData_gauge1 === void 0 ? void 0 : (_firstData_gauge_axis = _firstData_gauge1.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),
661
+ color: getColor('Current', colorMap, isDarkTheme)
662
+ },
663
+ {
664
+ legend: 'Target',
665
+ size: ((_firstData_gauge_axis_range_1 = (_firstData_gauge2 = firstData.gauge) === null || _firstData_gauge2 === void 0 ? void 0 : (_firstData_gauge_axis1 = _firstData_gauge2.axis) === null || _firstData_gauge_axis1 === void 0 ? void 0 : (_firstData_gauge_axis_range1 = _firstData_gauge_axis1.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),
666
+ color: _colors.DataVizPalette.disabled
667
+ }
668
+ ];
669
+ let sublabel;
670
+ // let sublabelColor: string | undefined;
671
+ if ((_firstData_delta = firstData.delta) === null || _firstData_delta === void 0 ? void 0 : _firstData_delta.reference) {
672
+ const diff = firstData.value - firstData.delta.reference;
673
+ if (diff >= 0) {
674
+ sublabel = `\u25B2 ${diff}`;
675
+ // const color = getColorFromToken(DataVizPalette.success, isDarkTheme);
676
+ // sublabelColor = color;
677
+ } else {
678
+ sublabel = `\u25BC ${Math.abs(diff)}`;
679
+ // const color = getColorFromToken(DataVizPalette.error, isDarkTheme);
680
+ // sublabelColor = color;
404
681
  }
405
682
  }
406
- return jsonObject;
683
+ // const styles: GaugeChartProps['styles'] = {
684
+ // sublabel: {
685
+ // fill: sublabelColor,
686
+ // },
687
+ // };
688
+ const { chartTitle } = getTitles(input.layout);
689
+ var _firstData_value2;
690
+ return {
691
+ segments,
692
+ chartValue: (_firstData_value2 = firstData.value) !== null && _firstData_value2 !== void 0 ? _firstData_value2 : 0,
693
+ chartTitle,
694
+ sublabel,
695
+ // range values can be null
696
+ minValue: typeof ((_firstData_gauge3 = firstData.gauge) === null || _firstData_gauge3 === void 0 ? void 0 : (_firstData_gauge_axis2 = _firstData_gauge3.axis) === null || _firstData_gauge_axis2 === void 0 ? void 0 : (_firstData_gauge_axis_range2 = _firstData_gauge_axis2.range) === null || _firstData_gauge_axis_range2 === void 0 ? void 0 : _firstData_gauge_axis_range2[0]) === 'number' ? (_firstData_gauge4 = firstData.gauge) === null || _firstData_gauge4 === void 0 ? void 0 : (_firstData_gauge_axis3 = _firstData_gauge4.axis) === null || _firstData_gauge_axis3 === void 0 ? void 0 : (_firstData_gauge_axis_range3 = _firstData_gauge_axis3.range) === null || _firstData_gauge_axis_range3 === void 0 ? void 0 : _firstData_gauge_axis_range3[0] : undefined,
697
+ maxValue: typeof ((_firstData_gauge5 = firstData.gauge) === null || _firstData_gauge5 === void 0 ? void 0 : (_firstData_gauge_axis4 = _firstData_gauge5.axis) === null || _firstData_gauge_axis4 === void 0 ? void 0 : (_firstData_gauge_axis_range4 = _firstData_gauge_axis4.range) === null || _firstData_gauge_axis_range4 === void 0 ? void 0 : _firstData_gauge_axis_range4[1]) === 'number' ? (_firstData_gauge6 = firstData.gauge) === null || _firstData_gauge6 === void 0 ? void 0 : (_firstData_gauge_axis5 = _firstData_gauge6.axis) === null || _firstData_gauge_axis5 === void 0 ? void 0 : (_firstData_gauge_axis_range5 = _firstData_gauge_axis5.range) === null || _firstData_gauge_axis_range5 === void 0 ? void 0 : _firstData_gauge_axis_range5[1] : undefined,
698
+ chartValueFormat: ()=>{
699
+ var _firstData_value;
700
+ var _firstData_value_toString;
701
+ 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 : '';
702
+ },
703
+ // FIXME
704
+ // width: input.layout?.width,
705
+ // height: input.layout?.height ?? 220,
706
+ // TODO
707
+ // styles,
708
+ variant: ((_firstData_gauge7 = firstData.gauge) === null || _firstData_gauge7 === void 0 ? void 0 : (_firstData_gauge_steps1 = _firstData_gauge7.steps) === null || _firstData_gauge_steps1 === void 0 ? void 0 : _firstData_gauge_steps1.length) ? 'multiple-segments' : 'single-segment'
709
+ };
407
710
  };
408
- function isTypedArray(a) {
409
- return ArrayBuffer.isView(a) && !(a instanceof DataView);
410
- }
411
- function isArrayOrTypedArray(a) {
412
- return Array.isArray(a) || isTypedArray(a);
413
- }
414
711
  function isPlainObject(obj) {
415
712
  return Object.prototype.toString.call(obj) === '[object Object]' && Object.getPrototypeOf(obj).hasOwnProperty('hasOwnProperty');
416
713
  }
@@ -426,7 +723,7 @@ function crawlIntoTrace(container, i, astrPartial) {
426
723
  var item = container[stack[i]];
427
724
  var newAstrPartial = astrPartial + stack[i];
428
725
  if (i === stack.length - 1) {
429
- if (isArrayOrTypedArray(item)) {
726
+ if ((0, _chartutilities.isArrayOrTypedArray)(item)) {
430
727
  arrayAttributes.push(baseAttrName + newAstrPartial);
431
728
  }
432
729
  } else {
@@ -443,3 +740,120 @@ function crawlIntoTrace(container, i, astrPartial) {
443
740
  }
444
741
  }
445
742
  }
743
+ function getLineOptions(line) {
744
+ if (!line) {
745
+ return;
746
+ }
747
+ let lineOptions = {};
748
+ if (line.dash) {
749
+ lineOptions = {
750
+ ...lineOptions,
751
+ ...dashOptions[line.dash]
752
+ };
753
+ }
754
+ switch(line.shape){
755
+ case 'spline':
756
+ const smoothing = typeof line.smoothing === 'number' ? line.smoothing : 1;
757
+ lineOptions.curve = _d3shape.curveCardinal.tension(1 - smoothing / 1.3);
758
+ break;
759
+ case 'hv':
760
+ lineOptions.curve = 'stepAfter';
761
+ break;
762
+ case 'vh':
763
+ lineOptions.curve = 'stepBefore';
764
+ break;
765
+ case 'hvh':
766
+ lineOptions.curve = 'step';
767
+ break;
768
+ default:
769
+ lineOptions.curve = 'linear';
770
+ }
771
+ return Object.keys(lineOptions).length > 0 ? lineOptions : undefined;
772
+ }
773
+ const isStringArray = (arr)=>{
774
+ return (0, _chartutilities.isArrayOfType)(arr, (value)=>typeof value === 'string');
775
+ };
776
+ // TODO: Use binary search to find the appropriate bin for numeric value.
777
+ const findBinIndex = (bins, value, isString)=>{
778
+ if (typeof value === 'undefined' || value === null) {
779
+ return -1;
780
+ }
781
+ return isString ? bins.findIndex((bin)=>bin.includes(value)) : bins.findIndex((bin)=>value >= bin.x0 && value < bin.x1);
782
+ };
783
+ const getBinSize = (bin)=>{
784
+ return bin.x1 - bin.x0;
785
+ };
786
+ const getBinCenter = (bin)=>{
787
+ return (bin.x1 + bin.x0) / 2;
788
+ };
789
+ // TODO: Add support for date axes
790
+ const createBins = (data, binStart, binEnd, binSize)=>{
791
+ if (!data || data.length === 0) {
792
+ return [];
793
+ }
794
+ if (isStringArray(data)) {
795
+ const categories = Array.from(new Set(data));
796
+ const start = typeof binStart === 'number' ? Math.ceil(binStart) : 0;
797
+ const stop = typeof binEnd === 'number' ? Math.floor(binEnd) + 1 : categories.length;
798
+ const step = typeof binSize === 'number' ? binSize : 1;
799
+ return (0, _d3array.range)(start, stop, step).map((i)=>categories.slice(i, i + step));
800
+ }
801
+ const scale = (0, _d3scale.scaleLinear)().domain((0, _d3array.extent)(data)).nice();
802
+ let [minVal, maxVal] = scale.domain();
803
+ minVal = typeof binStart === 'number' ? binStart : minVal;
804
+ maxVal = typeof binEnd === 'number' ? binEnd : maxVal;
805
+ const binGenerator = (0, _d3array.bin)().domain([
806
+ minVal,
807
+ maxVal
808
+ ]);
809
+ if (typeof binSize === 'number') {
810
+ var _binSize_toString_split_;
811
+ const thresholds = [];
812
+ let th = minVal;
813
+ var _binSize_toString_split__length;
814
+ const tolerance = 1 / Math.pow(10, (_binSize_toString_split__length = (_binSize_toString_split_ = binSize.toString().split('.')[1]) === null || _binSize_toString_split_ === void 0 ? void 0 : _binSize_toString_split_.length) !== null && _binSize_toString_split__length !== void 0 ? _binSize_toString_split__length : 0);
815
+ while(maxVal + binSize - th > tolerance){
816
+ thresholds.push(th);
817
+ th += binSize;
818
+ }
819
+ minVal = thresholds[0];
820
+ maxVal = thresholds[thresholds.length - 1];
821
+ binGenerator.domain([
822
+ minVal,
823
+ maxVal
824
+ ]).thresholds(thresholds);
825
+ }
826
+ // NOTE: The last bin generated by d3Bin often has identical x0 and x1 values (both inclusive) and
827
+ // can be ignored if the highest value is already included in the previous bin.
828
+ return binGenerator(data);
829
+ };
830
+ const calculateHistFunc = (histfunc, bin)=>{
831
+ switch(histfunc){
832
+ case 'sum':
833
+ return (0, _d3array.sum)(bin);
834
+ case 'avg':
835
+ return bin.length === 0 ? 0 : (0, _d3array.sum)(bin) / bin.length;
836
+ case 'min':
837
+ var _d3Min;
838
+ return (_d3Min = (0, _d3array.min)(bin)) !== null && _d3Min !== void 0 ? _d3Min : 0;
839
+ case 'max':
840
+ var _d3Max;
841
+ return (_d3Max = (0, _d3array.max)(bin)) !== null && _d3Max !== void 0 ? _d3Max : 0;
842
+ default:
843
+ return bin.length;
844
+ }
845
+ };
846
+ const calculateHistNorm = (histnorm, value, total, dx, dy = 1)=>{
847
+ switch(histnorm){
848
+ case 'percent':
849
+ return total === 0 ? 0 : value / total * 100;
850
+ case 'probability':
851
+ return total === 0 ? 0 : value / total;
852
+ case 'density':
853
+ return dx * dy === 0 ? 0 : value / (dx * dy);
854
+ case 'probability density':
855
+ return total * dx * dy === 0 ? 0 : value / (total * dx * dy);
856
+ default:
857
+ return value;
858
+ }
859
+ };