@fluentui/react-charts 9.2.1 → 9.2.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 (201) hide show
  1. package/CHANGELOG.md +57 -2
  2. package/dist/index.d.ts +168 -15
  3. package/lib/ChartTable.js +1 -0
  4. package/lib/ChartTable.js.map +1 -0
  5. package/lib/components/AreaChart/AreaChart.js +4 -1
  6. package/lib/components/AreaChart/AreaChart.js.map +1 -1
  7. package/lib/components/AreaChart/useAreaChartStyles.styles.js +2 -1
  8. package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
  9. package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js +2 -1
  10. package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
  11. package/lib/components/ChartTable/ChartTable.js +58 -0
  12. package/lib/components/ChartTable/ChartTable.js.map +1 -0
  13. package/lib/components/ChartTable/ChartTable.types.js +1 -0
  14. package/lib/components/ChartTable/ChartTable.types.js.map +1 -0
  15. package/lib/components/ChartTable/index.js +3 -0
  16. package/lib/components/ChartTable/index.js.map +1 -0
  17. package/lib/components/ChartTable/useChartTableStyles.styles.js +93 -0
  18. package/lib/components/ChartTable/useChartTableStyles.styles.js.map +1 -0
  19. package/lib/components/ChartTable/useChartTableStyles.styles.raw.js +55 -0
  20. package/lib/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -0
  21. package/lib/components/CommonComponents/CartesianChart.js +170 -100
  22. package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
  23. package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
  24. package/lib/components/CommonComponents/ChartPopover.types.js.map +1 -1
  25. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +13 -0
  26. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  27. package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +12 -0
  28. package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
  29. package/lib/components/DeclarativeChart/DeclarativeChart.js +180 -102
  30. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  31. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +100 -0
  32. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
  33. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +890 -211
  34. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  35. package/lib/components/DonutChart/DonutChart.js +2 -2
  36. package/lib/components/DonutChart/DonutChart.js.map +1 -1
  37. package/lib/components/DonutChart/DonutChart.types.js.map +1 -1
  38. package/lib/components/DonutChart/Pie/Pie.js.map +1 -1
  39. package/lib/components/FunnelChart/FunnelChart.js.map +1 -1
  40. package/lib/components/GanttChart/GanttChart.js.map +1 -1
  41. package/lib/components/GanttChart/useGanttChartStyles.styles.js +2 -1
  42. package/lib/components/GanttChart/useGanttChartStyles.styles.js.map +1 -1
  43. package/lib/components/GanttChart/useGanttChartStyles.styles.raw.js +2 -1
  44. package/lib/components/GanttChart/useGanttChartStyles.styles.raw.js.map +1 -1
  45. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +185 -144
  46. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  47. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +2 -1
  48. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  49. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +2 -1
  50. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
  51. package/lib/components/HeatMapChart/HeatMapChart.js +175 -114
  52. package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
  53. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js +2 -1
  54. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
  55. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +2 -1
  56. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
  57. package/lib/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
  58. package/lib/components/HorizontalBarChart/HorizontalBarChart.types.js.map +1 -1
  59. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +26 -6
  60. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  61. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +2 -1
  62. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
  63. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +2 -1
  64. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
  65. package/lib/components/Legends/Legends.js.map +1 -1
  66. package/lib/components/Legends/OverflowMenu.js.map +1 -1
  67. package/lib/components/LineChart/LineChart.js +251 -78
  68. package/lib/components/LineChart/LineChart.js.map +1 -1
  69. package/lib/components/LineChart/LineChart.types.js.map +1 -1
  70. package/lib/components/LineChart/useLineChartStyles.styles.js +10 -3
  71. package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  72. package/lib/components/LineChart/useLineChartStyles.styles.raw.js +14 -2
  73. package/lib/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
  74. package/lib/components/ScatterChart/ScatterChart.js +56 -37
  75. package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
  76. package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -1
  77. package/lib/components/ScatterChart/useScatterChartStyles.styles.js +21 -4
  78. package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  79. package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js +16 -3
  80. package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
  81. package/lib/components/VerticalBarChart/VerticalBarChart.js +38 -14
  82. package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  83. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +2 -1
  84. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  85. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +2 -1
  86. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
  87. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +214 -96
  88. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  89. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
  90. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +2 -1
  91. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
  92. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +2 -1
  93. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
  94. package/lib/index.js +1 -0
  95. package/lib/index.js.map +1 -1
  96. package/lib/types/DataPoint.js.map +1 -1
  97. package/lib/utilities/FocusableTooltipText.js.map +1 -1
  98. package/lib/utilities/utilities.js +41 -42
  99. package/lib/utilities/utilities.js.map +1 -1
  100. package/lib/utilities/vbc-utils.js +24 -0
  101. package/lib/utilities/vbc-utils.js.map +1 -1
  102. package/lib-commonjs/ChartTable.js +6 -0
  103. package/lib-commonjs/ChartTable.js.map +1 -0
  104. package/lib-commonjs/components/AreaChart/AreaChart.js +4 -1
  105. package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
  106. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js +2 -1
  107. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
  108. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js +2 -1
  109. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
  110. package/lib-commonjs/components/ChartTable/ChartTable.js +69 -0
  111. package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -0
  112. package/lib-commonjs/components/ChartTable/ChartTable.types.js +6 -0
  113. package/lib-commonjs/components/ChartTable/ChartTable.types.js.map +1 -0
  114. package/lib-commonjs/components/ChartTable/index.js +8 -0
  115. package/lib-commonjs/components/ChartTable/index.js.map +1 -0
  116. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js +196 -0
  117. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js.map +1 -0
  118. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js +69 -0
  119. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -0
  120. package/lib-commonjs/components/CommonComponents/CartesianChart.js +169 -98
  121. package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
  122. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
  123. package/lib-commonjs/components/CommonComponents/ChartPopover.types.js.map +1 -1
  124. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +13 -0
  125. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  126. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +12 -0
  127. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
  128. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +176 -100
  129. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  130. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +128 -0
  131. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
  132. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +909 -209
  133. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  134. package/lib-commonjs/components/DonutChart/DonutChart.js +1 -1
  135. package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
  136. package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -1
  137. package/lib-commonjs/components/DonutChart/Pie/Pie.js.map +1 -1
  138. package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -1
  139. package/lib-commonjs/components/GanttChart/GanttChart.js.map +1 -1
  140. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js +2 -1
  141. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js.map +1 -1
  142. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.raw.js +2 -1
  143. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.raw.js.map +1 -1
  144. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +183 -142
  145. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  146. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +2 -1
  147. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  148. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +2 -1
  149. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
  150. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +174 -113
  151. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
  152. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js +2 -1
  153. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
  154. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +2 -1
  155. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
  156. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
  157. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.types.js.map +1 -1
  158. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +25 -5
  159. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  160. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +2 -1
  161. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
  162. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +2 -1
  163. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
  164. package/lib-commonjs/components/Legends/Legends.js.map +1 -1
  165. package/lib-commonjs/components/Legends/OverflowMenu.js.map +1 -1
  166. package/lib-commonjs/components/LineChart/LineChart.js +250 -78
  167. package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
  168. package/lib-commonjs/components/LineChart/LineChart.types.js.map +1 -1
  169. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js +12 -3
  170. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  171. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js +14 -2
  172. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
  173. package/lib-commonjs/components/ScatterChart/ScatterChart.js +56 -37
  174. package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
  175. package/lib-commonjs/components/ScatterChart/ScatterChart.types.js.map +1 -1
  176. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js +30 -3
  177. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  178. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js +15 -2
  179. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
  180. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +37 -13
  181. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  182. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +2 -1
  183. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  184. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +2 -1
  185. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
  186. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +213 -95
  187. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  188. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
  189. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +2 -1
  190. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
  191. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +2 -1
  192. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
  193. package/lib-commonjs/index.js +1 -0
  194. package/lib-commonjs/index.js.map +1 -1
  195. package/lib-commonjs/types/DataPoint.js.map +1 -1
  196. package/lib-commonjs/utilities/FocusableTooltipText.js.map +1 -1
  197. package/lib-commonjs/utilities/utilities.js +44 -41
  198. package/lib-commonjs/utilities/utilities.js.map +1 -1
  199. package/lib-commonjs/utilities/vbc-utils.js +27 -0
  200. package/lib-commonjs/utilities/vbc-utils.js.map +1 -1
  201. package/package.json +10 -10
@@ -1,10 +1,13 @@
1
- /* eslint-disable one-var */ /* eslint-disable vars-on-top */ /* eslint-disable no-var */ /* eslint-disable @typescript-eslint/no-explicit-any */ import * as React from 'react';
1
+ /* eslint-disable one-var */ /* eslint-disable vars-on-top */ /* eslint-disable no-var */ import * as React from 'react';
2
2
  import { bin as d3Bin, extent as d3Extent, sum as d3Sum, min as d3Min, max as d3Max, range as d3Range } from 'd3-array';
3
3
  import { scaleLinear as d3ScaleLinear } from 'd3-scale';
4
- import { DataVizPalette, getColorFromToken, getNextColor } from '../../utilities/colors';
5
- import { findNumericMinMaxOfY } from '../../utilities/utilities';
6
- import { isArrayOfType, isArrayOrTypedArray, isDate, isDateArray, isNumberArray, isYearArray } from '@fluentui/chart-utilities';
4
+ import { format as d3Format } from 'd3-format';
5
+ import { DataVizPalette, getColorFromToken } from '../../utilities/colors';
6
+ import { findNumericMinMaxOfY, formatScientificLimitWidth, MIN_DONUT_RADIUS } from '../../utilities/utilities';
7
+ import { isArrayOrTypedArray, isDate, isDateArray, isNumberArray, isStringArray, isYearArray, isInvalidValue } from '@fluentui/chart-utilities';
7
8
  import { curveCardinal as d3CurveCardinal } from 'd3-shape';
9
+ import { getOpacity, extractColor, resolveColor } from './PlotlyColorAdapter';
10
+ import { rgb } from 'd3-color';
8
11
  const dashOptions = {
9
12
  dot: {
10
13
  strokeDasharray: '1, 5',
@@ -53,6 +56,7 @@ function getTitles(layout) {
53
56
  };
54
57
  return titles;
55
58
  }
59
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
56
60
  export const correctYearMonth = (xValues)=>{
57
61
  const presentYear = new Date().getFullYear();
58
62
  if (xValues.length > 0 && Array.isArray(xValues[0])) {
@@ -62,32 +66,35 @@ export const correctYearMonth = (xValues)=>{
62
66
  const parsedDate = `${possiblyMonthValue} 01, ${presentYear}`;
63
67
  return isDate(parsedDate) ? new Date(parsedDate) : null;
64
68
  });
65
- for(let i = dates.length - 1; i > 0; i--){
66
- const currentMonth = dates[i].getMonth();
67
- const previousMonth = dates[i - 1].getMonth();
68
- const currentYear = dates[i].getFullYear();
69
- const previousYear = dates[i - 1].getFullYear();
69
+ const filteredDateIndexPairs = dates.map((date, index)=>[
70
+ date,
71
+ index
72
+ ]).filter(([date])=>date !== null);
73
+ for(let i = filteredDateIndexPairs.length - 1; i > 0; i--){
74
+ const currentDate = filteredDateIndexPairs[i][0];
75
+ const previousDate = filteredDateIndexPairs[i - 1][0];
76
+ const currentMonth = currentDate.getMonth();
77
+ const previousMonth = previousDate.getMonth();
78
+ const currentYear = currentDate.getFullYear();
79
+ const previousYear = previousDate.getFullYear();
70
80
  if (previousMonth >= currentMonth) {
71
- dates[i - 1].setFullYear(dates[i].getFullYear() - 1);
81
+ filteredDateIndexPairs[i - 1][0].setFullYear(currentYear - 1);
72
82
  } else if (previousYear > currentYear) {
73
- dates[i - 1].setFullYear(currentYear);
83
+ filteredDateIndexPairs[i - 1][0].setFullYear(currentYear);
74
84
  }
85
+ dates[filteredDateIndexPairs[i - 1][1]] = filteredDateIndexPairs[i - 1][0];
75
86
  }
76
87
  xValues = xValues.map((month, index)=>{
88
+ if (dates[index] === null) {
89
+ return null;
90
+ }
77
91
  return `${month} 01, ${dates[index].getFullYear()}`;
78
92
  });
79
93
  return xValues;
80
94
  };
81
- export const getColor = (legendLabel, colorMap, isDarkTheme)=>{
82
- if (!colorMap.current.has(legendLabel)) {
83
- const nextColor = getNextColor(colorMap.current.size + 1, 0, isDarkTheme);
84
- colorMap.current.set(legendLabel, nextColor);
85
- return nextColor;
86
- }
87
- return colorMap.current.get(legendLabel);
88
- };
89
- const usesSecondaryYScale = (series)=>{
90
- return series.yaxis === 'y2';
95
+ const usesSecondaryYScale = (series, layout)=>{
96
+ var _layout_yaxis2, _layout_yaxis21;
97
+ 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');
91
98
  };
92
99
  const getSecondaryYAxisValues = (data, layout, maxAllowedMinY, minAllowedMaxY)=>{
93
100
  var _layout_yaxis2, _layout_yaxis21, _layout_yaxis2_title, _layout_yaxis22;
@@ -95,7 +102,7 @@ const getSecondaryYAxisValues = (data, layout, maxAllowedMinY, minAllowedMaxY)=>
95
102
  let yMinValue;
96
103
  let yMaxValue;
97
104
  data.forEach((series)=>{
98
- if (usesSecondaryYScale(series)) {
105
+ if (usesSecondaryYScale(series, layout)) {
99
106
  containsSecondaryYAxis = true;
100
107
  const yValues = series.y;
101
108
  if (yValues) {
@@ -125,29 +132,60 @@ const getSecondaryYAxisValues = (data, layout, maxAllowedMinY, minAllowedMaxY)=>
125
132
  }
126
133
  };
127
134
  };
128
- export const transformPlotlyJsonToDonutProps = (input, colorMap, isDarkTheme)=>{
129
- var _firstData_labels, _input_layout, _input_layout1, _input_layout2, _input_layout3;
135
+ export const _getGaugeAxisColor = (colorway, colorwayType, color, colorMap, isDarkTheme)=>{
136
+ const extractedColors = extractColor(colorway, colorwayType, color, colorMap, isDarkTheme);
137
+ return resolveColor(extractedColors, 0, '', colorMap, isDarkTheme);
138
+ };
139
+ export const resolveXAxisPoint = (x, isXYearCategory, isXString, isXDate, isXNumber)=>{
140
+ if (x === null || x === undefined) {
141
+ return '';
142
+ }
143
+ if (isXYearCategory) {
144
+ return x.toString();
145
+ }
146
+ if (isXString) {
147
+ if (isXDate) {
148
+ const date = new Date(x);
149
+ return date;
150
+ }
151
+ if (isXNumber) {
152
+ return parseFloat(x);
153
+ }
154
+ return x;
155
+ }
156
+ return x;
157
+ };
158
+ export const transformPlotlyJsonToDonutProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
159
+ var _input_layout, _input_layout_template_layout, _input_layout_template, _input_layout1, _input_layout2, _firstData_marker, _firstData_labels, _input_layout3, _input_layout4, _input_layout5, _input_layout6;
130
160
  const firstData = input.data[0];
161
+ var _input_layout_piecolorway, _input_layout_piecolorway1;
162
+ // extract colors for each series only once
163
+ // use piecolorway if available
164
+ // otherwise, default to colorway from template
165
+ 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);
131
166
  const mapLegendToDataPoint = {};
132
167
  (_firstData_labels = firstData.labels) === null || _firstData_labels === void 0 ? void 0 : _firstData_labels.forEach((label, index)=>{
133
- var _firstData_values;
134
- const color = getColor(label, colorMap, isDarkTheme);
135
- //ToDo how to handle string data?
136
- const value = typeof ((_firstData_values = firstData.values) === null || _firstData_values === void 0 ? void 0 : _firstData_values[index]) === 'number' ? firstData.values[index] : 1;
137
- if (!mapLegendToDataPoint[label]) {
138
- mapLegendToDataPoint[label] = {
139
- legend: label,
168
+ const value = getNumberAtIndexOrDefault(firstData.values, index);
169
+ if (isInvalidValue(value) || value < 0) {
170
+ return;
171
+ }
172
+ const legend = `${label}`;
173
+ // resolve color for each legend from the extracted colors
174
+ const color = resolveColor(colors, index, legend, colorMap, isDarkTheme);
175
+ if (!mapLegendToDataPoint[legend]) {
176
+ mapLegendToDataPoint[legend] = {
177
+ legend,
140
178
  data: value,
141
179
  color
142
180
  };
143
181
  } else {
144
- mapLegendToDataPoint[label].data += value;
182
+ mapLegendToDataPoint[legend].data += value;
145
183
  }
146
184
  });
147
185
  var _input_layout_width;
148
- 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;
186
+ 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;
149
187
  var _input_layout_height;
150
- const 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 : 220;
188
+ 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;
151
189
  const hideLabels = firstData.textinfo ? ![
152
190
  'value',
153
191
  'percent',
@@ -155,82 +193,110 @@ export const transformPlotlyJsonToDonutProps = (input, colorMap, isDarkTheme)=>{
155
193
  ].includes(firstData.textinfo) : false;
156
194
  const donutMarginHorizontal = hideLabels ? 0 : 80;
157
195
  const donutMarginVertical = 40 + (hideLabels ? 0 : 40);
158
- const innerRadius = firstData.hole ? firstData.hole * (Math.min(width - donutMarginHorizontal, height - donutMarginVertical) / 2) : 0;
196
+ const innerRadius = firstData.hole ? firstData.hole * (Math.min(width - donutMarginHorizontal, height - donutMarginVertical) / 2) : MIN_DONUT_RADIUS;
159
197
  const { chartTitle } = getTitles(input.layout);
160
198
  return {
161
199
  data: {
162
200
  chartTitle,
163
201
  chartData: Object.values(mapLegendToDataPoint)
164
202
  },
165
- hideLegend: ((_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.showlegend) === false ? true : false,
166
- width: (_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : _input_layout3.width,
203
+ hideLegend: ((_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : _input_layout5.showlegend) === false ? true : false,
204
+ width: (_input_layout6 = input.layout) === null || _input_layout6 === void 0 ? void 0 : _input_layout6.width,
167
205
  height,
168
206
  innerRadius,
169
207
  hideLabels,
170
208
  showLabelsInPercent: firstData.textinfo ? [
171
209
  'percent',
172
210
  'label+percent'
173
- ].includes(firstData.textinfo) : true
211
+ ].includes(firstData.textinfo) : true,
212
+ roundCorners: true
174
213
  };
175
214
  };
176
- export const transformPlotlyJsonToVSBCProps = (input, colorMap, isDarkTheme, fallbackVSBC)=>{
177
- var _input_layout, _input_layout1;
215
+ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme, fallbackVSBC)=>{
216
+ var _input_layout, _input_layout1, _vsbcData_;
178
217
  const mapXToDataPoints = {};
179
218
  let yMaxValue = 0;
180
219
  const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
181
- const { legends, hideLegend } = getLegendProps(input.data, input.layout);
220
+ const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
221
+ let colorScale = undefined;
182
222
  let yMinValue = 0;
183
223
  input.data.forEach((series, index1)=>{
184
- var _series_x;
224
+ var _input_layout_coloraxis_colorscale, _input_layout_coloraxis, _input_layout, _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout1, _series_marker3, _input_layout_template_layout1, _input_layout_template1, _input_layout2, _series_line;
225
+ if (((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_coloraxis = _input_layout.coloraxis) === null || _input_layout_coloraxis === void 0 ? void 0 : (_input_layout_coloraxis_colorscale = _input_layout_coloraxis.colorscale) === null || _input_layout_coloraxis_colorscale === void 0 ? void 0 : _input_layout_coloraxis_colorscale.length) && isArrayOrTypedArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) && ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length > 0 && typeof ((_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[0]) === 'number') {
226
+ colorScale = createColorScale(input.layout, series);
227
+ }
185
228
  const isXYearCategory = isYearArray(series.x); // Consider year as categorical not numeric continuous axis
186
- (_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x.forEach((x, index2)=>{
187
- var _series_y;
188
- if (!mapXToDataPoints[x]) {
189
- mapXToDataPoints[x] = {
190
- xAxisPoint: isXYearCategory ? x.toString() : x,
191
- chartData: [],
192
- lineData: []
193
- };
194
- }
195
- const legend = legends[index1];
196
- var _series_y_index2;
197
- 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;
198
- if (series.type === 'bar') {
199
- const color = getColor(legend, colorMap, isDarkTheme);
200
- mapXToDataPoints[x].chartData.push({
201
- legend,
202
- data: yVal,
203
- color
204
- });
205
- yMaxValue = Math.max(yMaxValue, yVal);
206
- } else if (series.type === 'scatter' || !!fallbackVSBC) {
207
- var _series_line;
208
- const color = getColor(legend, colorMap, isDarkTheme);
209
- const lineOptions = getLineOptions(series.line);
210
- const dashType = ((_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.dash) || 'solid';
211
- const legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot' ? 'dottedLine' : 'default';
212
- mapXToDataPoints[x].lineData.push({
213
- legend,
214
- legendShape,
215
- y: yVal,
216
- color,
217
- ...lineOptions ? {
218
- lineOptions
219
- } : {},
220
- useSecondaryYScale: usesSecondaryYScale(series)
221
- });
222
- if (!usesSecondaryYScale(series)) {
223
- yMaxValue = Math.max(yMaxValue, yVal);
229
+ // extract bar colors for each series only once
230
+ const extractedBarColors = extractColor((_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, (_series_marker3 = series.marker) === null || _series_marker3 === void 0 ? void 0 : _series_marker3.color, colorMap, isDarkTheme);
231
+ // extract line colors for each series only once
232
+ const extractedLineColors = extractColor((_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_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);
233
+ const xValues = series.x;
234
+ const isXDate = isDateArray(xValues);
235
+ const isXString = isStringArray(xValues);
236
+ const isXNumber = isNumberArray(xValues);
237
+ const validXYRanges = getValidXYRanges(series);
238
+ validXYRanges.forEach(([rangeStart, rangeEnd], rangeIdx)=>{
239
+ const rangeXValues = series.x.slice(rangeStart, rangeEnd);
240
+ const rangeYValues = series.y.slice(rangeStart, rangeEnd);
241
+ rangeXValues.forEach((x, index2)=>{
242
+ var _series_marker, _series_marker1, _series_marker_color, _series_marker2;
243
+ if (!mapXToDataPoints[x]) {
244
+ mapXToDataPoints[x] = {
245
+ xAxisPoint: resolveXAxisPoint(x, isXYearCategory, isXString, isXDate, isXNumber),
246
+ chartData: [],
247
+ lineData: []
248
+ };
224
249
  }
225
- }
226
- yMaxValue = Math.max(yMaxValue, yVal);
227
- yMinValue = Math.min(yMinValue, yVal);
250
+ const legend = legends[index1];
251
+ // resolve color for each legend's bars from the colorscale or extracted colors
252
+ 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, isDarkTheme);
253
+ const opacity = getOpacity(series, index2);
254
+ const yVal = rangeYValues[index2];
255
+ if (series.type === 'bar') {
256
+ var _rgb_copy_formatHex8;
257
+ mapXToDataPoints[x].chartData.push({
258
+ legend,
259
+ data: yVal,
260
+ color: (_rgb_copy_formatHex8 = rgb(color).copy({
261
+ opacity
262
+ }).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
263
+ });
264
+ if (typeof yVal === 'number') {
265
+ yMaxValue = Math.max(yMaxValue, yVal);
266
+ }
267
+ } else if (series.type === 'scatter' || !!fallbackVSBC) {
268
+ var _series_mode;
269
+ const lineColor = resolveColor(extractedLineColors, index1, legend, colorMap, isDarkTheme);
270
+ const lineOptions = !((_series_mode = series.mode) === null || _series_mode === void 0 ? void 0 : _series_mode.includes('text')) ? getLineOptions(series.line) : undefined;
271
+ const legendShape = getLegendShape(series);
272
+ var _rgb_copy_formatHex81;
273
+ mapXToDataPoints[x].lineData.push({
274
+ legend: legend + (validXYRanges.length > 1 ? `.${rangeIdx + 1}` : ''),
275
+ legendShape,
276
+ y: yVal,
277
+ color: (_rgb_copy_formatHex81 = rgb(lineColor).copy({
278
+ opacity
279
+ }).formatHex8()) !== null && _rgb_copy_formatHex81 !== void 0 ? _rgb_copy_formatHex81 : color,
280
+ lineOptions: {
281
+ ...lineOptions !== null && lineOptions !== void 0 ? lineOptions : {},
282
+ mode: series.mode
283
+ },
284
+ useSecondaryYScale: usesSecondaryYScale(series, input.layout)
285
+ });
286
+ if (!usesSecondaryYScale(series, input.layout) && typeof yVal === 'number') {
287
+ yMaxValue = Math.max(yMaxValue, yVal);
288
+ yMinValue = Math.min(yMinValue, yVal);
289
+ }
290
+ }
291
+ yMaxValue = Math.max(yMaxValue, yVal);
292
+ });
228
293
  });
229
294
  });
230
295
  const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
296
+ const vsbcData = Object.values(mapXToDataPoints);
231
297
  var _input_layout_height;
232
298
  return {
233
- data: Object.values(mapXToDataPoints),
299
+ data: vsbcData,
234
300
  width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
235
301
  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,
236
302
  barWidth: 'auto',
@@ -241,19 +307,49 @@ export const transformPlotlyJsonToVSBCProps = (input, colorMap, isDarkTheme, fal
241
307
  yAxisTitle,
242
308
  mode: 'plotly',
243
309
  ...secondaryYAxisValues,
310
+ wrapXAxisLables: typeof ((_vsbcData_ = vsbcData[0]) === null || _vsbcData_ === void 0 ? void 0 : _vsbcData_.xAxisPoint) === 'string',
244
311
  hideTickOverlap: true,
245
312
  barGapMax: 2,
246
- hideLegend
313
+ hideLegend,
314
+ roundCorners: true,
315
+ showYAxisLables: true,
316
+ noOfCharsToTruncate: 20,
317
+ showYAxisLablesTooltip: true,
318
+ ...getAxisCategoryOrderProps(input.data, input.layout)
247
319
  };
248
320
  };
249
- export const transformPlotlyJsonToGVBCProps = (input, colorMap, isDarkTheme)=>{
250
- var _input_layout, _input_layout1;
321
+ const createColorScale = (layout, series)=>{
322
+ var _layout_coloraxis, _series_marker, _layout_coloraxis1, _layout_coloraxis2;
323
+ const scale = layout === null || layout === void 0 ? void 0 : (_layout_coloraxis = layout.coloraxis) === null || _layout_coloraxis === void 0 ? void 0 : _layout_coloraxis.colorscale;
324
+ const colorValues = (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color;
325
+ var _layout_coloraxis_cmin, _layout_coloraxis_cmax;
326
+ const [dMin, dMax] = [
327
+ (_layout_coloraxis_cmin = layout === null || layout === void 0 ? void 0 : (_layout_coloraxis1 = layout.coloraxis) === null || _layout_coloraxis1 === void 0 ? void 0 : _layout_coloraxis1.cmin) !== null && _layout_coloraxis_cmin !== void 0 ? _layout_coloraxis_cmin : Math.min(...colorValues),
328
+ (_layout_coloraxis_cmax = layout === null || layout === void 0 ? void 0 : (_layout_coloraxis2 = layout.coloraxis) === null || _layout_coloraxis2 === void 0 ? void 0 : _layout_coloraxis2.cmax) !== null && _layout_coloraxis_cmax !== void 0 ? _layout_coloraxis_cmax : Math.max(...colorValues)
329
+ ];
330
+ // Normalize colorscale domain to actual data domain
331
+ const scaleDomain = scale.map(([pos])=>dMin + pos * (dMax - dMin));
332
+ const scaleColors = scale.map((item)=>item[1]);
333
+ return d3ScaleLinear().domain(scaleDomain).range(scaleColors);
334
+ };
335
+ export const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
336
+ var _input_layout, _input_layout1, _gvbcData_;
251
337
  const mapXToDataPoints = {};
252
338
  const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, 0, 0);
253
- const { legends, hideLegend } = getLegendProps(input.data, input.layout);
339
+ const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
340
+ let colorScale = undefined;
254
341
  input.data.forEach((series, index1)=>{
255
- var _series_x;
342
+ var _input_layout_coloraxis_colorscale, _input_layout_coloraxis, _input_layout, _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout1, _series_marker3, _series_x;
343
+ if (((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_coloraxis = _input_layout.coloraxis) === null || _input_layout_coloraxis === void 0 ? void 0 : (_input_layout_coloraxis_colorscale = _input_layout_coloraxis.colorscale) === null || _input_layout_coloraxis_colorscale === void 0 ? void 0 : _input_layout_coloraxis_colorscale.length) && isArrayOrTypedArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) && ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length > 0 && typeof ((_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[0]) === 'number') {
344
+ colorScale = createColorScale(input.layout, series);
345
+ }
346
+ // extract colors for each series only once
347
+ const extractedColors = extractColor((_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, (_series_marker3 = series.marker) === null || _series_marker3 === void 0 ? void 0 : _series_marker3.color, colorMap, isDarkTheme);
256
348
  (_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x.forEach((x, index2)=>{
349
+ var _series_y;
350
+ if (isInvalidValue(x) || isInvalidValue((_series_y = series.y) === null || _series_y === void 0 ? void 0 : _series_y[index2])) {
351
+ return;
352
+ }
257
353
  if (!mapXToDataPoints[x]) {
258
354
  mapXToDataPoints[x] = {
259
355
  name: x.toString(),
@@ -261,25 +357,30 @@ export const transformPlotlyJsonToGVBCProps = (input, colorMap, isDarkTheme)=>{
261
357
  };
262
358
  }
263
359
  if (series.type === 'bar') {
264
- var _series_y;
360
+ var _series_marker, _series_marker1, _series_marker_color, _series_marker2;
265
361
  const legend = legends[index1];
266
- const color = getColor(legend, colorMap, isDarkTheme);
267
- var _series_y_index2;
362
+ // resolve color for each legend's bars from the colorscale or extracted colors
363
+ 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(extractedColors, index2, legend, colorMap, isDarkTheme);
364
+ const opacity = getOpacity(series, index2);
365
+ var _rgb_copy_formatHex8;
268
366
  mapXToDataPoints[x].series.push({
269
367
  key: legend,
270
- 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,
368
+ data: series.y[index2],
271
369
  xAxisCalloutData: x,
272
- color,
370
+ color: (_rgb_copy_formatHex8 = rgb(color).copy({
371
+ opacity
372
+ }).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
273
373
  legend,
274
- useSecondaryYScale: usesSecondaryYScale(series)
374
+ useSecondaryYScale: usesSecondaryYScale(series, input.layout)
275
375
  });
276
376
  }
277
377
  });
278
378
  });
279
379
  const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
380
+ const gvbcData = Object.values(mapXToDataPoints);
280
381
  var _input_layout_height;
281
382
  return {
282
- data: Object.values(mapXToDataPoints),
383
+ data: gvbcData,
283
384
  width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
284
385
  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,
285
386
  barWidth: 'auto',
@@ -289,30 +390,47 @@ export const transformPlotlyJsonToGVBCProps = (input, colorMap, isDarkTheme)=>{
289
390
  mode: 'plotly',
290
391
  ...secondaryYAxisValues,
291
392
  hideTickOverlap: true,
292
- hideLegend
393
+ wrapXAxisLables: typeof ((_gvbcData_ = gvbcData[0]) === null || _gvbcData_ === void 0 ? void 0 : _gvbcData_.name) === 'string',
394
+ hideLegend,
395
+ roundCorners: true,
396
+ ...getAxisCategoryOrderProps(input.data, input.layout)
293
397
  };
294
398
  };
295
- export const transformPlotlyJsonToVBCProps = (input, colorMap, isDarkTheme)=>{
296
- var _input_layout, _input_layout1;
399
+ export const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
400
+ var _input_layout, _input_layout1, _vbcData_;
297
401
  const vbcData = [];
298
- const { legends, hideLegend } = getLegendProps(input.data, input.layout);
402
+ const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
403
+ let colorScale = undefined;
299
404
  input.data.forEach((series, seriesIdx)=>{
300
- var _series_xbins, _series_xbins1, _series_xbins2;
405
+ var _input_layout_coloraxis_colorscale, _input_layout_coloraxis, _input_layout, _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout1, _series_marker3, _series_xbins, _series_xbins1, _series_xbins2;
301
406
  if (!series.x) {
302
407
  return;
303
408
  }
304
- const isXString = isStringArray(series.x);
409
+ if (((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_coloraxis = _input_layout.coloraxis) === null || _input_layout_coloraxis === void 0 ? void 0 : (_input_layout_coloraxis_colorscale = _input_layout_coloraxis.colorscale) === null || _input_layout_coloraxis_colorscale === void 0 ? void 0 : _input_layout_coloraxis_colorscale.length) && isArrayOrTypedArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) && ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length > 0 && typeof ((_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[0]) === 'number') {
410
+ colorScale = createColorScale(input.layout, series);
411
+ }
412
+ // extract colors for each series only once
413
+ const extractedColors = extractColor((_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, (_series_marker3 = series.marker) === null || _series_marker3 === void 0 ? void 0 : _series_marker3.color, colorMap, isDarkTheme);
414
+ const xValues = [];
415
+ const yValues = [];
416
+ series.x.forEach((xVal, index)=>{
417
+ const yVal = getNumberAtIndexOrDefault(series.y, index);
418
+ if (isInvalidValue(xVal) || isInvalidValue(yVal)) {
419
+ return;
420
+ }
421
+ xValues.push(xVal);
422
+ yValues.push(yVal);
423
+ });
424
+ const isXString = isStringArray(xValues);
305
425
  // TODO: In case of a single bin, add an empty bin of the same size to prevent the
306
426
  // default bar width from being used and ensure the bar spans the full intended range.
307
- 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);
427
+ 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);
308
428
  const yBins = xBins.map(()=>[]);
309
429
  let total = 0;
310
- series.x.forEach((xVal, index)=>{
430
+ xValues.forEach((xVal, index)=>{
311
431
  const binIdx = findBinIndex(xBins, xVal, isXString);
312
432
  if (binIdx !== -1) {
313
- var _series_y;
314
- var _series_y_index;
315
- 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);
433
+ yBins[binIdx].push(yValues[index]);
316
434
  }
317
435
  });
318
436
  const y = yBins.map((bin)=>{
@@ -321,14 +439,20 @@ export const transformPlotlyJsonToVBCProps = (input, colorMap, isDarkTheme)=>{
321
439
  return yVal;
322
440
  });
323
441
  xBins.forEach((bin, index)=>{
442
+ var _series_marker, _series_marker1, _series_marker_color, _series_marker2;
324
443
  const legend = legends[seriesIdx];
325
- const color = getColor(legend, colorMap, isDarkTheme);
444
+ // resolve color for each legend's bars from the colorscale or extracted colors
445
+ 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, isDarkTheme);
446
+ const opacity = getOpacity(series, index);
326
447
  const yVal = calculateHistNorm(series.histnorm, y[index], total, isXString ? bin.length : getBinSize(bin));
448
+ var _rgb_copy_formatHex8;
327
449
  vbcData.push({
328
450
  x: isXString ? bin.join(', ') : getBinCenter(bin),
329
451
  y: yVal,
330
452
  legend,
331
- color,
453
+ color: (_rgb_copy_formatHex8 = rgb(color).copy({
454
+ opacity
455
+ }).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
332
456
  ...isXString ? {} : {
333
457
  xAxisCalloutData: `[${bin.x0} - ${bin.x1})`
334
458
  }
@@ -346,54 +470,102 @@ export const transformPlotlyJsonToVBCProps = (input, colorMap, isDarkTheme)=>{
346
470
  yAxisTitle,
347
471
  mode: 'histogram',
348
472
  hideTickOverlap: true,
473
+ wrapXAxisLables: typeof ((_vbcData_ = vbcData[0]) === null || _vbcData_ === void 0 ? void 0 : _vbcData_.x) === 'string',
349
474
  maxBarWidth: 50,
350
- hideLegend
475
+ hideLegend,
476
+ roundCorners: true,
477
+ ...getAxisCategoryOrderProps(input.data, input.layout)
351
478
  };
352
479
  };
353
- export const transformPlotlyJsonToScatterChartProps = (input, isAreaChart, colorMap, isDarkTheme)=>{
480
+ export const transformPlotlyJsonToAreaChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
481
+ return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'area', colorMap, colorwayType, isDarkTheme);
482
+ };
483
+ export const transformPlotlyJsonToLineChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
484
+ return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'line', colorMap, colorwayType, isDarkTheme);
485
+ };
486
+ export const transformPlotlyJsonToScatterChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
487
+ return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'scatter', colorMap, colorwayType, isDarkTheme);
488
+ };
489
+ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme)=>{
490
+ var _input_data_;
491
+ const isScatterMarkers = [
492
+ 'markers',
493
+ 'text+markers',
494
+ 'markers+text',
495
+ 'lines+markers',
496
+ 'markers+line',
497
+ 'text+lines+markers'
498
+ ].includes((_input_data_ = input.data[0]) === null || _input_data_ === void 0 ? void 0 : _input_data_.mode);
499
+ const isAreaChart = chartType === 'area';
500
+ const isScatterChart = chartType === 'scatter';
354
501
  const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
355
502
  let mode = 'tonexty';
356
- const { legends, hideLegend } = getLegendProps(input.data, input.layout);
503
+ const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
357
504
  const chartData = input.data.map((series, index)=>{
358
- var _series_line;
505
+ var _series_mode, _series_line, _series_marker, _series_line1, _input_layout_template_layout, _input_layout_template, _input_layout, _series_mode1;
506
+ 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;
507
+ // extract colors for each series only once
508
+ 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);
359
509
  const xValues = series.x;
360
- const isString = typeof xValues[0] === 'string';
510
+ const isXString = isStringArray(xValues);
361
511
  const isXDate = isDateArray(xValues);
362
512
  const isXNumber = isNumberArray(xValues);
513
+ const isXYearCategory = isYearArray(series.x); // Consider year as categorical not numeric continuous axis
363
514
  const legend = legends[index];
364
- const lineColor = getColor(legend, colorMap, isDarkTheme);
515
+ // resolve color for each legend's lines from the extracted colors
516
+ const seriesColor = resolveColor(extractedColors, index, legend, colorMap, isDarkTheme);
517
+ const seriesOpacity = getOpacity(series, index);
365
518
  mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
366
- const lineOptions = getLineOptions(series.line);
367
- const dashType = ((_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.dash) || 'solid';
368
- const legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot' ? 'dottedLine' : 'default';
369
- return {
370
- legend,
371
- legendShape,
372
- data: xValues.map((x, i)=>{
373
- var _series_marker, _series_marker1;
374
- return {
375
- x: isString ? isXDate ? new Date(x) : isXNumber ? parseFloat(x) : x : x,
376
- y: series.y[i],
377
- ...Array.isArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.size) ? {
378
- markerSize: series.marker.size[i]
379
- } : typeof ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.size) === 'number' ? {
380
- markerSize: series.marker.size
381
- } : {}
382
- };
383
- }),
384
- color: lineColor,
385
- ...lineOptions ? {
386
- lineOptions
387
- } : {},
388
- useSecondaryYScale: usesSecondaryYScale(series)
389
- };
390
- });
519
+ const lineOptions = !((_series_mode1 = series.mode) === null || _series_mode1 === void 0 ? void 0 : _series_mode1.includes('text')) ? getLineOptions(series.line) : undefined;
520
+ const legendShape = getLegendShape(series);
521
+ const validXYRanges = getValidXYRanges(series);
522
+ return validXYRanges.map(([rangeStart, rangeEnd], rangeIdx)=>{
523
+ var _series_marker;
524
+ const rangeXValues = xValues.slice(rangeStart, rangeEnd);
525
+ const rangeYValues = series.y.slice(rangeStart, rangeEnd);
526
+ const markerSizes = isArrayOrTypedArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.size) ? series.marker.size.slice(rangeStart, rangeEnd) : [];
527
+ const textValues = Array.isArray(series.text) ? series.text.slice(rangeStart, rangeEnd) : undefined;
528
+ var _rgb_copy_formatHex8;
529
+ return {
530
+ legend,
531
+ legendShape,
532
+ data: rangeXValues.map((x, i)=>{
533
+ var _series_marker, _series_marker1;
534
+ return {
535
+ x: resolveXAxisPoint(x, isXYearCategory, isXString, isXDate, isXNumber),
536
+ y: rangeYValues[i],
537
+ ...Array.isArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.size) ? {
538
+ markerSize: markerSizes[i]
539
+ } : typeof ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.size) === 'number' ? {
540
+ markerSize: series.marker.size
541
+ } : {},
542
+ ...textValues ? {
543
+ text: textValues[i]
544
+ } : {}
545
+ };
546
+ }),
547
+ color: (_rgb_copy_formatHex8 = rgb(seriesColor).copy({
548
+ opacity: seriesOpacity
549
+ }).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : seriesColor,
550
+ lineOptions: {
551
+ ...lineOptions !== null && lineOptions !== void 0 ? lineOptions : {},
552
+ mode: series.mode
553
+ },
554
+ useSecondaryYScale: usesSecondaryYScale(series, input.layout)
555
+ };
556
+ });
557
+ }).flat();
391
558
  const yMinMaxValues = findNumericMinMaxOfY(chartData);
392
559
  const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
560
+ const numDataPoints = chartData.reduce((total, lineChartPoints)=>total + lineChartPoints.data.length, 0);
393
561
  const chartProps = {
394
562
  chartTitle,
395
563
  lineChartData: chartData
396
564
  };
565
+ const scatterChartProps = {
566
+ chartTitle,
567
+ scatterChartData: chartData
568
+ };
397
569
  if (isAreaChart) {
398
570
  var _input_layout, _input_layout1;
399
571
  var _input_layout_height;
@@ -408,13 +580,14 @@ export const transformPlotlyJsonToScatterChartProps = (input, isAreaChart, color
408
580
  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,
409
581
  hideTickOverlap: true,
410
582
  useUTC: false,
411
- hideLegend
583
+ hideLegend,
584
+ optimizeLargeData: numDataPoints > 1000
412
585
  };
413
586
  } else {
414
587
  var _input_layout2, _input_layout3;
415
588
  var _input_layout_height1;
416
589
  return {
417
- data: chartProps,
590
+ data: isScatterChart ? scatterChartProps : chartProps,
418
591
  supportNegativeData: true,
419
592
  xAxisTitle,
420
593
  yAxisTitle,
@@ -426,26 +599,42 @@ export const transformPlotlyJsonToScatterChartProps = (input, isAreaChart, color
426
599
  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,
427
600
  hideTickOverlap: true,
428
601
  useUTC: false,
429
- hideLegend
602
+ hideLegend,
603
+ optimizeLargeData: numDataPoints > 1000
430
604
  };
431
605
  }
432
606
  };
433
- export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, colorMap, isDarkTheme)=>{
607
+ export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
434
608
  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;
435
- const { legends, hideLegend } = getLegendProps(input.data, input.layout);
609
+ const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
610
+ let colorScale = undefined;
436
611
  const chartData = input.data.map((series, index)=>{
612
+ var _input_layout_coloraxis_colorscale, _input_layout_coloraxis, _input_layout, _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout1, _series_marker3;
613
+ if (((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_coloraxis = _input_layout.coloraxis) === null || _input_layout_coloraxis === void 0 ? void 0 : (_input_layout_coloraxis_colorscale = _input_layout_coloraxis.colorscale) === null || _input_layout_coloraxis_colorscale === void 0 ? void 0 : _input_layout_coloraxis_colorscale.length) && isArrayOrTypedArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) && ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length > 0 && typeof ((_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[0]) === 'number') {
614
+ colorScale = createColorScale(input.layout, series);
615
+ }
616
+ // extract colors for each series only once
617
+ const extractedColors = extractColor((_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, (_series_marker3 = series.marker) === null || _series_marker3 === void 0 ? void 0 : _series_marker3.color, colorMap, isDarkTheme);
437
618
  const legend = legends[index];
438
- const color = getColor(legend, colorMap, isDarkTheme);
439
619
  return series.y.map((yValue, i)=>{
620
+ var _series_x, _series_marker, _series_marker1, _series_marker_color, _series_marker2;
621
+ if (isInvalidValue((_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x[i]) || isInvalidValue(yValue)) {
622
+ return null;
623
+ }
624
+ // resolve color for each legend's bars from the colorscale or extracted colors
625
+ 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, isDarkTheme);
626
+ const opacity = getOpacity(series, i);
627
+ var _rgb_copy_formatHex8;
440
628
  return {
441
629
  x: series.x[i],
442
630
  y: yValue,
443
631
  legend,
444
- color
632
+ color: (_rgb_copy_formatHex8 = rgb(color).copy({
633
+ opacity
634
+ }).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
445
635
  };
446
- });
447
- }).reverse().flat()//reversing the order to invert the Y bars order as required by plotly.
448
- .reverse();
636
+ }).filter((point)=>point !== null);
637
+ }).flat();
449
638
  var _input_layout_height;
450
639
  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;
451
640
  var _input_layout_margin_l;
@@ -471,31 +660,43 @@ export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, colorMap,
471
660
  hideTickOverlap: true,
472
661
  noOfCharsToTruncate: 20,
473
662
  showYAxisLablesTooltip: true,
474
- hideLegend
663
+ hideLegend,
664
+ roundCorners: true,
665
+ ...getAxisCategoryOrderProps(input.data, input.layout)
475
666
  };
476
667
  };
477
- export const transformPlotlyJsonToHeatmapProps = (input)=>{
478
- var _input_layout, _input_layout1;
668
+ export const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
669
+ var _input_layout, _input_layout_coloraxis, _input_layout1, _input_layout_template_layout, _input_layout_template, _input_layout2, _input_layout_template_data_histogram2d_, _input_layout_template_data_histogram2d, _input_layout_template_data, _input_layout_template1, _input_layout3, _input_layout_template_data_heatmap_, _input_layout_template_data_heatmap, _input_layout_template_data1, _input_layout_template2, _input_layout4, _input_layout5, _input_layout6;
479
670
  const firstData = input.data[0];
480
671
  const heatmapDataPoints = [];
481
672
  let zMin = Number.POSITIVE_INFINITY;
482
673
  let zMax = Number.NEGATIVE_INFINITY;
483
674
  if (firstData.type === 'histogram2d') {
484
- var _firstData_xbins, _firstData_xbins1, _firstData_xbins2, _firstData_ybins, _firstData_ybins1, _firstData_ybins2, _firstData_x;
485
- const isXString = isStringArray(firstData.x);
486
- const isYString = isStringArray(firstData.y);
487
- 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);
488
- 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);
489
- const zBins = yBins.map(()=>xBins.map(()=>[]));
490
- let total = 0;
675
+ var _firstData_x, _firstData_xbins, _firstData_xbins1, _firstData_xbins2, _firstData_ybins, _firstData_ybins1, _firstData_ybins2;
676
+ const xValues = [];
677
+ const yValues = [];
678
+ const zValues = [];
491
679
  (_firstData_x = firstData.x) === null || _firstData_x === void 0 ? void 0 : _firstData_x.forEach((xVal, index)=>{
492
680
  var _firstData_y;
681
+ const zVal = getNumberAtIndexOrDefault(firstData.z, index);
682
+ if (isInvalidValue(xVal) || isInvalidValue((_firstData_y = firstData.y) === null || _firstData_y === void 0 ? void 0 : _firstData_y[index]) || isInvalidValue(zVal)) {
683
+ return;
684
+ }
685
+ xValues.push(xVal);
686
+ yValues.push(firstData.y[index]);
687
+ zValues.push(zVal);
688
+ });
689
+ const isXString = isStringArray(xValues);
690
+ const isYString = isStringArray(yValues);
691
+ 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);
692
+ 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);
693
+ const zBins = yBins.map(()=>xBins.map(()=>[]));
694
+ let total = 0;
695
+ xValues.forEach((xVal, index)=>{
493
696
  const xBinIdx = findBinIndex(xBins, xVal, isXString);
494
- const yBinIdx = findBinIndex(yBins, (_firstData_y = firstData.y) === null || _firstData_y === void 0 ? void 0 : _firstData_y[index], isYString);
697
+ const yBinIdx = findBinIndex(yBins, yValues[index], isYString);
495
698
  if (xBinIdx !== -1 && yBinIdx !== -1) {
496
- var _firstData_z;
497
- var _firstData_z_index;
498
- 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);
699
+ zBins[yBinIdx][xBinIdx].push(zValues[index]);
499
700
  }
500
701
  });
501
702
  const z = zBins.map((row)=>{
@@ -523,7 +724,8 @@ export const transformPlotlyJsonToHeatmapProps = (input)=>{
523
724
  } else {
524
725
  var _firstData_x1;
525
726
  (_firstData_x1 = firstData.x) === null || _firstData_x1 === void 0 ? void 0 : _firstData_x1.forEach((xVal, xIdx)=>{
526
- var _firstData_y;
727
+ var // eslint-disable-next-line @typescript-eslint/no-explicit-any
728
+ _firstData_y;
527
729
  (_firstData_y = firstData.y) === null || _firstData_y === void 0 ? void 0 : _firstData_y.forEach((yVal, yIdx)=>{
528
730
  var _firstData_z_yIdx, _firstData_z, _input_layout_xaxis, _input_layout, _input_layout_yaxis, _input_layout1;
529
731
  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];
@@ -557,8 +759,23 @@ export const transformPlotlyJsonToHeatmapProps = (input)=>{
557
759
  getColorFromToken(DataVizPalette.color2),
558
760
  getColorFromToken(DataVizPalette.color3)
559
761
  ];
560
- const domainValuesForColorScale = Array.isArray(firstData.colorscale) ? firstData.colorscale.map((arr)=>arr[0] * (zMax - zMin) + zMin) : defaultDomain;
561
- const rangeValuesForColorScale = Array.isArray(firstData.colorscale) ? firstData.colorscale.map((arr)=>arr[1]) : defaultRange;
762
+ var _firstData_colorscale, _ref, _ref1, _ref2, _ref3;
763
+ 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_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.colorscale) !== null && _ref !== void 0 ? _ref : (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_coloraxis = _input_layout1.coloraxis) === null || _input_layout_coloraxis === void 0 ? void 0 : _input_layout_coloraxis.colorscale) !== null && _ref1 !== void 0 ? _ref1 : (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : (_input_layout_template = _input_layout2.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_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_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_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_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;
764
+ // determine if the types diverging, sequential or sequentialminus are present in colorscale
765
+ if (colorscale && typeof colorscale === 'object' && ('diverging' in colorscale || 'sequential' in colorscale || 'sequentialminus' in colorscale)) {
766
+ const isDivergent = zMin < 0 && zMax > 0; // Data spans both positive and negative values
767
+ const isSequential = zMin >= 0; // Data is entirely positive
768
+ const isSequentialMinus = zMax <= 0; // Data is entirely negative
769
+ if (isDivergent) {
770
+ colorscale = colorscale === null || colorscale === void 0 ? void 0 : colorscale.diverging;
771
+ } else if (isSequential) {
772
+ colorscale = colorscale === null || colorscale === void 0 ? void 0 : colorscale.sequential;
773
+ } else if (isSequentialMinus) {
774
+ colorscale = colorscale === null || colorscale === void 0 ? void 0 : colorscale.sequentialminus;
775
+ }
776
+ }
777
+ const domainValuesForColorScale = Array.isArray(colorscale) ? colorscale.map((arr)=>arr[0] * (zMax - zMin) + zMin) : defaultDomain;
778
+ const rangeValuesForColorScale = Array.isArray(colorscale) ? colorscale.map((arr)=>arr[1]) : defaultRange;
562
779
  const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
563
780
  var _input_layout_height;
564
781
  return {
@@ -573,33 +790,44 @@ export const transformPlotlyJsonToHeatmapProps = (input)=>{
573
790
  xAxisTitle,
574
791
  yAxisTitle,
575
792
  sortOrder: 'none',
576
- width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
577
- 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,
793
+ width: (_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : _input_layout5.width,
794
+ height: (_input_layout_height = (_input_layout6 = input.layout) === null || _input_layout6 === void 0 ? void 0 : _input_layout6.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
578
795
  hideTickOverlap: true,
579
796
  noOfCharsToTruncate: 20,
580
- showYAxisLablesTooltip: true
797
+ showYAxisLablesTooltip: true,
798
+ wrapXAxisLables: true,
799
+ ...getAxisCategoryOrderProps([
800
+ firstData
801
+ ], input.layout)
581
802
  };
582
803
  };
583
- export const transformPlotlyJsonToSankeyProps = (input, colorMap, isDarkTheme)=>{
584
- var _node_label, _input_layout, _input_layout1;
804
+ export const transformPlotlyJsonToSankeyProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
805
+ var _input_layout_template_layout, _input_layout_template, _input_layout, _node_label, _input_layout1, _input_layout2;
585
806
  const { link, node } = input.data[0];
586
807
  var _link_value;
587
- const validLinks = ((_link_value = link === null || link === void 0 ? void 0 : link.value) !== null && _link_value !== void 0 ? _link_value : []).map((val, index)=>({
808
+ const validLinks = ((_link_value = link === null || link === void 0 ? void 0 : link.value) !== null && _link_value !== void 0 ? _link_value : []).map((val, index)=>{
809
+ var _link_source, _link_target;
810
+ 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])) {
811
+ return null;
812
+ }
813
+ return {
588
814
  value: val,
589
815
  source: link === null || link === void 0 ? void 0 : link.source[index],
590
816
  target: link === null || link === void 0 ? void 0 : link.target[index]
591
- }))// eslint-disable-next-line @typescript-eslint/no-shadow
592
- // Filter out negative nodes, unequal nodes and self-references (circular links)
593
- .filter((x)=>x.source >= 0 && x.target >= 0 && x.source !== x.target);
817
+ };
818
+ })// Filter out negative nodes, unequal nodes and self-references (circular links)
819
+ .filter((x)=>x !== null && x.source >= 0 && x.target >= 0 && x.source !== x.target);
820
+ 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);
594
821
  const sankeyChartData = {
595
822
  nodes: (_node_label = node.label) === null || _node_label === void 0 ? void 0 : _node_label.map((label, index)=>{
596
- const color = getColor(label, colorMap, isDarkTheme);
823
+ const color = resolveColor(extractedNodeColors, index, label, colorMap, isDarkTheme);
597
824
  return {
598
825
  nodeId: index,
599
826
  name: label,
600
827
  color
601
828
  };
602
829
  }),
830
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
603
831
  links: validLinks.map((validLink, index)=>{
604
832
  return {
605
833
  ...validLink
@@ -618,18 +846,20 @@ export const transformPlotlyJsonToSankeyProps = (input, colorMap, isDarkTheme)=>
618
846
  chartTitle,
619
847
  SankeyChartData: sankeyChartData
620
848
  },
621
- width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
622
- 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
849
+ width: (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.width,
850
+ 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 : 468
623
851
  };
624
852
  };
625
- export const transformPlotlyJsonToGaugeProps = (input, colorMap, isDarkTheme)=>{
626
- 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, _input_layout, _input_layout1, _firstData_gauge_steps1, _firstData_gauge7;
853
+ export const transformPlotlyJsonToGaugeProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
854
+ 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;
627
855
  const firstData = input.data[0];
856
+ const stepsColors = ((_firstData_gauge = firstData.gauge) === null || _firstData_gauge === void 0 ? void 0 : _firstData_gauge.steps) ? firstData.gauge.steps.map((step)=>step.color) : undefined;
857
+ 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);
628
858
  var _firstData_gauge_axis_range_, _firstData_value, _firstData_gauge_axis_range_1, _firstData_value1;
629
- 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)=>{
859
+ 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)=>{
630
860
  var _step_range, _step_range1;
631
861
  const legend = step.name || `Segment ${index + 1}`;
632
- const color = getColor(legend, colorMap, isDarkTheme);
862
+ const color = resolveColor(extractedColors, index, legend, colorMap, isDarkTheme);
633
863
  return {
634
864
  legend,
635
865
  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]),
@@ -638,34 +868,36 @@ export const transformPlotlyJsonToGaugeProps = (input, colorMap, isDarkTheme)=>{
638
868
  }) : [
639
869
  {
640
870
  legend: 'Current',
641
- 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),
642
- color: getColor('Current', colorMap, isDarkTheme)
871
+ 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),
872
+ 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)
643
873
  },
644
874
  {
645
875
  legend: 'Target',
646
- 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),
876
+ 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),
647
877
  color: DataVizPalette.disabled
648
878
  }
649
879
  ];
650
880
  let sublabel;
651
- // let sublabelColor: string | undefined;
881
+ let sublabelColor;
652
882
  if ((_firstData_delta = firstData.delta) === null || _firstData_delta === void 0 ? void 0 : _firstData_delta.reference) {
653
883
  const diff = firstData.value - firstData.delta.reference;
654
884
  if (diff >= 0) {
885
+ var _input_layout_template_layout2, _input_layout_template2, _input_layout4, _firstData_delta_increasing, _firstData_delta1;
655
886
  sublabel = `\u25B2 ${diff}`;
656
- // const color = getColorFromToken(DataVizPalette.success, isDarkTheme);
657
- // sublabelColor = color;
887
+ 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);
888
+ const color = resolveColor(extractedIncreasingDeltaColors, 0, '', colorMap, isDarkTheme);
889
+ sublabelColor = color;
658
890
  } else {
891
+ var _input_layout_template_layout3, _input_layout_template3, _input_layout5, _firstData_delta_decreasing, _firstData_delta2;
659
892
  sublabel = `\u25BC ${Math.abs(diff)}`;
660
- // const color = getColorFromToken(DataVizPalette.error, isDarkTheme);
661
- // sublabelColor = color;
893
+ const extractedDecreasingDeltaColors = extractColor((_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, 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);
894
+ const color = resolveColor(extractedDecreasingDeltaColors, 0, '', colorMap, isDarkTheme);
895
+ sublabelColor = color;
662
896
  }
663
897
  }
664
- // const styles: GaugeChartProps['styles'] = {
665
- // sublabel: {
666
- // fill: sublabelColor,
667
- // },
668
- // };
898
+ const styles = {
899
+ sublabel: sublabelColor
900
+ };
669
901
  const { chartTitle } = getTitles(input.layout);
670
902
  var _firstData_value2, _input_layout_height;
671
903
  return {
@@ -674,18 +906,168 @@ export const transformPlotlyJsonToGaugeProps = (input, colorMap, isDarkTheme)=>{
674
906
  chartTitle,
675
907
  sublabel,
676
908
  // range values can be null
677
- 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,
678
- 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,
909
+ 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,
910
+ 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,
679
911
  chartValueFormat: ()=>{
680
912
  var _firstData_value;
681
913
  var _firstData_value_toString;
682
914
  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 : '';
683
915
  },
684
- width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
685
- 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 : 220,
916
+ width: (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.width,
917
+ 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,
686
918
  // TODO
687
919
  // styles,
688
- 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'
920
+ 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',
921
+ styles,
922
+ roundCorners: true
923
+ };
924
+ };
925
+ const cleanText = (text)=>{
926
+ return text.replace(/&lt;[^&]*?&gt;/g, '').replace(/<[^>]*>/g, '').replace(/&lt;br&gt;|\\u003cbr\\u003e|<br>/gi, '').replace(/\$[^$]*\$/g, '$').trim();
927
+ };
928
+ const formatValue = (value, colIndex, cells)=>{
929
+ if (value === null || typeof value === 'boolean') {
930
+ return value;
931
+ }
932
+ const formatStr = Array.isArray(cells.format) ? cells.format[colIndex] : cells.format;
933
+ const prefix = Array.isArray(cells.prefix) ? cells.prefix[colIndex] : cells.prefix;
934
+ const suffix = Array.isArray(cells.suffix) ? cells.suffix[colIndex] : cells.suffix;
935
+ let formatted = value;
936
+ if (typeof value === 'number') {
937
+ if (typeof formatStr === 'string') {
938
+ try {
939
+ formatted = d3Format(formatStr)(value);
940
+ } catch {
941
+ formatted = formatScientificLimitWidth(value);
942
+ }
943
+ } else {
944
+ formatted = formatScientificLimitWidth(value);
945
+ }
946
+ }
947
+ return `${prefix !== null && prefix !== void 0 ? prefix : ''}${formatted}${suffix !== null && suffix !== void 0 ? suffix : ''}`;
948
+ };
949
+ export const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
950
+ var _tableData_cells, _input_layout_template_data, _input_layout_template, _input_layout, _input_layout_font, _input_layout1, _tableData_header, _tableData_header1, _input_layout_template_data1, _input_layout_template1, _input_layout2, _input_layout3, _input_layout4;
951
+ const tableData = input.data[0];
952
+ const normalizeHeaders = (values, header)=>{
953
+ const cleanedValues = Array.isArray(values[0]) ? values.map((row)=>row.map((cell)=>cleanText(cell)).filter(Boolean).join(' ')) : values.map((cell)=>cleanText(cell));
954
+ return cleanedValues.map((value, colIndex)=>{
955
+ var _header_font, _header_font1, _header_fill;
956
+ const fontColorRaw = header === null || header === void 0 ? void 0 : (_header_font = header.font) === null || _header_font === void 0 ? void 0 : _header_font.color;
957
+ let fontColor;
958
+ if (Array.isArray(fontColorRaw)) {
959
+ const colorEntry = fontColorRaw[colIndex];
960
+ if (Array.isArray(colorEntry)) {
961
+ fontColor = typeof colorEntry[0] === 'string' ? colorEntry[0] : undefined;
962
+ } else if (typeof colorEntry === 'string') {
963
+ fontColor = colorEntry;
964
+ }
965
+ } else if (typeof fontColorRaw === 'string') {
966
+ fontColor = fontColorRaw;
967
+ }
968
+ const fontSizeRaw = header === null || header === void 0 ? void 0 : (_header_font1 = header.font) === null || _header_font1 === void 0 ? void 0 : _header_font1.size;
969
+ let fontSize;
970
+ if (Array.isArray(fontSizeRaw)) {
971
+ fontSize = Array.isArray(fontSizeRaw[0]) ? fontSizeRaw[0][colIndex] : fontSizeRaw[colIndex];
972
+ } else if (typeof fontSizeRaw === 'number') {
973
+ fontSize = fontSizeRaw;
974
+ }
975
+ const updatedColIndex = colIndex >= 1 ? 1 : 0;
976
+ const fillColorRaw = header === null || header === void 0 ? void 0 : (_header_fill = header.fill) === null || _header_fill === void 0 ? void 0 : _header_fill.color;
977
+ const backgroundColor = Array.isArray(fillColorRaw) ? fillColorRaw[updatedColIndex] : fillColorRaw;
978
+ const textAlignRaw = header === null || header === void 0 ? void 0 : header.align;
979
+ const textAlign = Array.isArray(textAlignRaw) ? textAlignRaw[colIndex] : textAlignRaw;
980
+ const style = {
981
+ ...typeof fontColor === 'string' ? {
982
+ color: fontColor
983
+ } : {},
984
+ ...typeof fontSize === 'number' ? {
985
+ fontSize
986
+ } : {},
987
+ ...typeof backgroundColor === 'string' ? {
988
+ backgroundColor
989
+ } : {},
990
+ ...textAlign ? {
991
+ textAlign
992
+ } : {}
993
+ };
994
+ return {
995
+ value,
996
+ style
997
+ };
998
+ });
999
+ };
1000
+ var _tableData_cells_values;
1001
+ 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 : [];
1002
+ const cells = tableData.cells.font ? 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[0].cells;
1003
+ const rows = columns[0].map((_, rowIndex)=>columns.map((col, colIndex)=>{
1004
+ var _cells_font, _cells_font1, _cells_fill;
1005
+ const cellValue = col[rowIndex];
1006
+ const cleanValue = typeof cellValue === 'string' ? cleanText(cellValue) : cellValue;
1007
+ const formattedValue = typeof cleanValue === 'string' || typeof cleanValue === 'number' ? formatValue(cleanValue, colIndex, cells) : cleanValue;
1008
+ const rawFontColor = cells === null || cells === void 0 ? void 0 : (_cells_font = cells.font) === null || _cells_font === void 0 ? void 0 : _cells_font.color;
1009
+ let fontColor;
1010
+ if (Array.isArray(rawFontColor)) {
1011
+ const entry = rawFontColor[colIndex];
1012
+ const colorValue = Array.isArray(entry) ? entry[rowIndex] : entry;
1013
+ fontColor = typeof colorValue === 'string' ? colorValue : undefined;
1014
+ } else if (typeof rawFontColor === 'string') {
1015
+ fontColor = rawFontColor;
1016
+ }
1017
+ const rawFontSize = cells === null || cells === void 0 ? void 0 : (_cells_font1 = cells.font) === null || _cells_font1 === void 0 ? void 0 : _cells_font1.size;
1018
+ let fontSize;
1019
+ if (Array.isArray(rawFontSize)) {
1020
+ const entry = rawFontSize[colIndex];
1021
+ const fontSizeValue = Array.isArray(entry) ? entry[rowIndex] : entry;
1022
+ fontSize = typeof fontSizeValue === 'number' ? fontSizeValue : undefined;
1023
+ } else if (typeof rawFontSize === 'number') {
1024
+ fontSize = rawFontSize;
1025
+ }
1026
+ const updatedColIndex = colIndex >= 1 ? 1 : 0;
1027
+ const rawBackgroundColor = cells === null || cells === void 0 ? void 0 : (_cells_fill = cells.fill) === null || _cells_fill === void 0 ? void 0 : _cells_fill.color;
1028
+ let backgroundColor;
1029
+ if (Array.isArray(rawBackgroundColor)) {
1030
+ const entry = rawBackgroundColor[updatedColIndex];
1031
+ const colorValue = Array.isArray(entry) ? entry[rowIndex] : entry;
1032
+ backgroundColor = typeof colorValue === 'string' ? colorValue : undefined;
1033
+ } else if (typeof rawBackgroundColor === 'string') {
1034
+ backgroundColor = rawBackgroundColor;
1035
+ }
1036
+ const rawTextAlign = Array.isArray(cells === null || cells === void 0 ? void 0 : cells.align) ? cells.align[colIndex] : cells === null || cells === void 0 ? void 0 : cells.align;
1037
+ const textAlign = rawTextAlign;
1038
+ const style = {
1039
+ ...fontColor ? {
1040
+ color: fontColor
1041
+ } : {},
1042
+ ...typeof fontSize === 'number' ? {
1043
+ fontSize
1044
+ } : {},
1045
+ ...backgroundColor ? {
1046
+ backgroundColor
1047
+ } : {},
1048
+ ...textAlign ? {
1049
+ textAlign
1050
+ } : {}
1051
+ };
1052
+ return {
1053
+ value: formattedValue,
1054
+ style
1055
+ };
1056
+ }));
1057
+ const styles = {
1058
+ root: {
1059
+ ...((_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) ? {
1060
+ fontSize: input.layout.font.size
1061
+ } : {}
1062
+ }
1063
+ };
1064
+ var _tableData_header_values;
1065
+ return {
1066
+ 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 : [], ((_tableData_header1 = tableData.header) === null || _tableData_header1 === void 0 ? void 0 : _tableData_header1.font) ? tableData.header : (_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_data1.table[0].header),
1067
+ rows,
1068
+ width: (_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : _input_layout3.width,
1069
+ height: (_input_layout4 = input.layout) === null || _input_layout4 === void 0 ? void 0 : _input_layout4.height,
1070
+ styles
689
1071
  };
690
1072
  };
691
1073
  export const projectPolarToCartesian = (input)=>{
@@ -693,34 +1075,47 @@ export const projectPolarToCartesian = (input)=>{
693
1075
  ...input
694
1076
  };
695
1077
  for(let sindex = 0; sindex < input.data.length; sindex++){
1078
+ var _series_r;
696
1079
  const series = input.data[sindex];
697
1080
  series.x = [];
698
1081
  series.y = [];
699
- for(let ptindex = 0; ptindex < series.r.length; ptindex++){
1082
+ var _series_r_length;
1083
+ for(let ptindex = 0; ptindex < ((_series_r_length = (_series_r = series.r) === null || _series_r === void 0 ? void 0 : _series_r.length) !== null && _series_r_length !== void 0 ? _series_r_length : 0); ptindex++){
1084
+ var _series_theta, _series_r1;
1085
+ if (isInvalidValue((_series_theta = series.theta) === null || _series_theta === void 0 ? void 0 : _series_theta[ptindex]) || isInvalidValue((_series_r1 = series.r) === null || _series_r1 === void 0 ? void 0 : _series_r1[ptindex])) {
1086
+ continue;
1087
+ }
700
1088
  const thetaRad = series.theta[ptindex] * Math.PI / 180;
701
1089
  const radius = series.r[ptindex];
702
- series.x[ptindex] = radius * Math.cos(thetaRad);
703
- series.y[ptindex] = radius * Math.sin(thetaRad);
1090
+ series.x.push(radius * Math.cos(thetaRad));
1091
+ series.y.push(radius * Math.sin(thetaRad));
704
1092
  }
705
1093
  projection.data[sindex] = series;
706
1094
  }
707
1095
  return projection;
708
1096
  };
1097
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
709
1098
  function isPlainObject(obj) {
710
1099
  return Object.prototype.toString.call(obj) === '[object Object]' && Object.getPrototypeOf(obj).hasOwnProperty('hasOwnProperty');
711
1100
  }
1101
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
712
1102
  var arrayAttributes = [];
1103
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
713
1104
  var stack = [];
1105
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
714
1106
  var isArrayStack = [];
1107
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
715
1108
  var baseContainer, baseAttrName;
716
1109
  /**
717
1110
  * Interate iteratively through the trace object and find all the array attributes.
718
1111
  * 1 trace record = 1 series of data
719
1112
  * @param trace
720
- */ export function findArrayAttributes(trace) {
1113
+ */ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1114
+ export function findArrayAttributes(trace) {
721
1115
  // Init basecontainer and baseAttrName
722
1116
  crawlIntoTrace(baseContainer, 0, '');
723
1117
  }
1118
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
724
1119
  function crawlIntoTrace(container, i, astrPartial) {
725
1120
  var item = container[stack[i]];
726
1121
  var newAstrPartial = astrPartial + stack[i];
@@ -772,9 +1167,6 @@ function getLineOptions(line) {
772
1167
  }
773
1168
  return Object.keys(lineOptions).length > 0 ? lineOptions : undefined;
774
1169
  }
775
- const isStringArray = (arr)=>{
776
- return isArrayOfType(arr, (value)=>typeof value === 'string');
777
- };
778
1170
  // TODO: Use binary search to find the appropriate bin for numeric value.
779
1171
  const findBinIndex = (bins, value, isString)=>{
780
1172
  if (typeof value === 'undefined' || value === null) {
@@ -869,7 +1261,46 @@ const precisionRound = (value, precision)=>{
869
1261
  const factor = Math.pow(10, precision);
870
1262
  return Math.round(value * factor) / factor;
871
1263
  };
872
- const getLegendProps = (data, layout)=>{
1264
+ const getLegendShape = (series)=>{
1265
+ var _series_line, _series_mode;
1266
+ const dashType = ((_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.dash) || 'solid';
1267
+ if (dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot') {
1268
+ return 'dottedLine';
1269
+ } else if ((_series_mode = series.mode) === null || _series_mode === void 0 ? void 0 : _series_mode.includes('markers')) {
1270
+ return 'circle';
1271
+ }
1272
+ return 'default';
1273
+ };
1274
+ export const getAllupLegendsProps = (input, colorMap, colorwayType, isDarkTheme)=>{
1275
+ const allupLegends = [];
1276
+ // reduce on showlegend boolean propperty. reduce should return true if at least one series has showlegend true
1277
+ const toShowLegend = input.data.reduce((acc, series)=>{
1278
+ return acc || series.showlegend === true;
1279
+ }, false);
1280
+ if (toShowLegend) {
1281
+ input.data.forEach((series, index)=>{
1282
+ var _series_line, _series_marker, _input_layout_template_layout, _input_layout_template, _input_layout;
1283
+ const name = series.legendgroup;
1284
+ const color = ((_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);
1285
+ const legendShape = getLegendShape(series);
1286
+ const resolvedColor = 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, color, colorMap, isDarkTheme);
1287
+ if (name !== undefined && allupLegends.some((group)=>group.title === name) === false) {
1288
+ allupLegends.push({
1289
+ title: name,
1290
+ color: resolvedColor,
1291
+ shape: legendShape
1292
+ });
1293
+ }
1294
+ });
1295
+ }
1296
+ return {
1297
+ legends: allupLegends,
1298
+ centerLegends: true,
1299
+ enabledWrapLines: true,
1300
+ canSelectMultipleLegends: true
1301
+ };
1302
+ };
1303
+ const getLegendProps = (data, layout, isMultiPlot)=>{
873
1304
  const legends = [];
874
1305
  if (data.length === 1) {
875
1306
  legends.push(data[0].name || '');
@@ -878,9 +1309,257 @@ const getLegendProps = (data, layout)=>{
878
1309
  legends.push(series.name || `Series ${index + 1}`);
879
1310
  });
880
1311
  }
881
- const hideLegends = data.every((series)=>series.showlegend === false);
1312
+ const hideLegendsData = data.every((series)=>series.showlegend === false);
1313
+ 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;
882
1314
  return {
883
1315
  legends,
884
- hideLegend: (layout === null || layout === void 0 ? void 0 : layout.showlegend) === false ? true : hideLegends
1316
+ hideLegend: isMultiPlot || hideLegendsInferred || hideLegendsData
1317
+ };
1318
+ };
1319
+ export const getNumberAtIndexOrDefault = (data, index)=>{
1320
+ if (isArrayOrTypedArray(data)) {
1321
+ if (typeof data[index] !== 'number' || !isFinite(data[index])) {
1322
+ return;
1323
+ }
1324
+ return data[index];
1325
+ }
1326
+ return 1;
1327
+ };
1328
+ export const getValidXYRanges = (series)=>{
1329
+ if (!isArrayOrTypedArray(series.x) || !isArrayOrTypedArray(series.y)) {
1330
+ return [];
1331
+ }
1332
+ const ranges = [];
1333
+ let start = 0;
1334
+ let end = 0;
1335
+ for(; end < series.x.length; end++){
1336
+ if (isInvalidValue(series.x[end]) || isInvalidValue(series.y[end])) {
1337
+ if (end - start > 0) {
1338
+ ranges.push([
1339
+ start,
1340
+ end
1341
+ ]);
1342
+ }
1343
+ start = end + 1;
1344
+ }
1345
+ }
1346
+ if (end - start > 0) {
1347
+ ranges.push([
1348
+ start,
1349
+ end
1350
+ ]);
1351
+ }
1352
+ return ranges;
1353
+ };
1354
+ const getIndexFromKey = (key, pattern)=>{
1355
+ const normalizedKey = key.replace(pattern, '') === '' ? '1' : key.replace(pattern, '');
1356
+ return parseInt(normalizedKey, 10) - 1;
1357
+ };
1358
+ export const getGridProperties = (layout, isMultiPlot)=>{
1359
+ var _layout_annotations;
1360
+ const gridX = [];
1361
+ const gridY = [];
1362
+ const annotations = {};
1363
+ let templateRows = '1fr';
1364
+ let templateColumns = '1fr';
1365
+ const gridLayout = {};
1366
+ if (layout === undefined || layout === null || Object.keys(layout).length === 0) {
1367
+ return {
1368
+ templateRows,
1369
+ templateColumns,
1370
+ layout: gridLayout
1371
+ };
1372
+ }
1373
+ if (!layout.xaxis || !layout.yaxis) {
1374
+ return {
1375
+ templateRows,
1376
+ templateColumns,
1377
+ layout: gridLayout
1378
+ };
1379
+ }
1380
+ if (!isMultiPlot) {
1381
+ return {
1382
+ templateRows,
1383
+ templateColumns,
1384
+ layout: gridLayout
1385
+ };
1386
+ }
1387
+ Object.keys(layout).forEach((key)=>{
1388
+ if (key.startsWith('xaxis')) {
1389
+ var _layout_key, _layout_key1;
1390
+ const index = getIndexFromKey(key, 'xaxis');
1391
+ var _layout_key_anchor;
1392
+ 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';
1393
+ const anchorIndex = getIndexFromKey(anchor, 'y');
1394
+ if (index !== anchorIndex) {
1395
+ throw new Error(`Invalid layout: xaxis ${index + 1} anchor should be y${anchorIndex + 1}`);
1396
+ }
1397
+ var _layout_key_domain;
1398
+ gridX[index] = (_layout_key_domain = (_layout_key1 = layout[key]) === null || _layout_key1 === void 0 ? void 0 : _layout_key1.domain) !== null && _layout_key_domain !== void 0 ? _layout_key_domain : [];
1399
+ } else if (key.startsWith('yaxis')) {
1400
+ var _layout_key2, _layout_key3;
1401
+ const index = getIndexFromKey(key, 'yaxis');
1402
+ var _layout_key_anchor1;
1403
+ const anchor = (_layout_key_anchor1 = (_layout_key2 = layout[key]) === null || _layout_key2 === void 0 ? void 0 : _layout_key2.anchor) !== null && _layout_key_anchor1 !== void 0 ? _layout_key_anchor1 : 'x';
1404
+ const anchorIndex = getIndexFromKey(anchor, 'x');
1405
+ if (index !== anchorIndex) {
1406
+ var _layout_yaxis2;
1407
+ if (index === 1 && anchorIndex === 0 || ((_layout_yaxis2 = layout.yaxis2) === null || _layout_yaxis2 === void 0 ? void 0 : _layout_yaxis2.side) === 'right') {
1408
+ // Special case for secondary y axis where yaxis2 can anchor to x1
1409
+ return {
1410
+ templateRows,
1411
+ templateColumns
1412
+ };
1413
+ }
1414
+ throw new Error(`Invalid layout: yaxis ${index + 1} anchor should be x${anchorIndex + 1}`);
1415
+ }
1416
+ var _layout_key_domain1;
1417
+ gridY[index] = (_layout_key_domain1 = (_layout_key3 = layout[key]) === null || _layout_key3 === void 0 ? void 0 : _layout_key3.domain) !== null && _layout_key_domain1 !== void 0 ? _layout_key_domain1 : [];
1418
+ }
1419
+ });
1420
+ (_layout_annotations = layout.annotations) === null || _layout_annotations === void 0 ? void 0 : _layout_annotations.forEach((annotation)=>{
1421
+ const xMatches = gridX.flatMap((interval, idx)=>(annotation === null || annotation === void 0 ? void 0 : annotation.x) >= interval[0] && (annotation === null || annotation === void 0 ? void 0 : annotation.x) <= interval[1] ? [
1422
+ idx
1423
+ ] : []);
1424
+ const yMatch = gridY.findIndex((interval, yIndex)=>xMatches.includes(yIndex) && (annotation === null || annotation === void 0 ? void 0 : annotation.y) >= interval[0] && (annotation === null || annotation === void 0 ? void 0 : annotation.y) <= interval[1]);
1425
+ if (yMatch !== -1) {
1426
+ if (annotations[yMatch] === undefined) {
1427
+ annotations[yMatch] = {};
1428
+ }
1429
+ if ((annotation === null || annotation === void 0 ? void 0 : annotation.textangle) === 90) {
1430
+ annotations[yMatch].yAnnotation = annotation.text;
1431
+ } else {
1432
+ annotations[yMatch].xAnnotation = annotation.text;
1433
+ }
1434
+ }
1435
+ });
1436
+ if (gridX.length > 0) {
1437
+ const uniqueXIntervals = new Map();
1438
+ gridX.forEach((interval)=>{
1439
+ const key = `${interval[0]}-${interval[1]}`;
1440
+ if (!uniqueXIntervals.has(key)) {
1441
+ uniqueXIntervals.set(key, interval);
1442
+ }
1443
+ });
1444
+ const minXInterval = Math.min(...Array.from(uniqueXIntervals.values()).map((interval)=>interval[1] - interval[0]));
1445
+ templateColumns = Array.from(uniqueXIntervals.values()).map((interval)=>`${(interval[1] - interval[0]) / minXInterval}fr`).join(' ');
1446
+ let columnNumber = 1;
1447
+ let lastIntervalEnd = 0;
1448
+ gridX.forEach((interval, index)=>{
1449
+ if (interval.length === 0) {
1450
+ return;
1451
+ }
1452
+ const cellName = `x${index === 0 ? '' : index + 1}`;
1453
+ const annotationProps = annotations[index];
1454
+ const xAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.xAnnotation;
1455
+ if (interval[0] < lastIntervalEnd) {
1456
+ columnNumber = 1;
1457
+ }
1458
+ lastIntervalEnd = interval[1];
1459
+ const row = {
1460
+ row: -1,
1461
+ column: columnNumber,
1462
+ xAnnotation
1463
+ };
1464
+ gridLayout[cellName] = row;
1465
+ columnNumber += 1;
1466
+ });
1467
+ }
1468
+ const numColumns = Math.max(...Object.values(gridLayout).map((cell)=>{
1469
+ var _cell_column;
1470
+ return (_cell_column = cell.column) !== null && _cell_column !== void 0 ? _cell_column : 0;
1471
+ }));
1472
+ const columnFill = {};
1473
+ for(let i = 1; i <= numColumns; i++){
1474
+ columnFill[i] = {
1475
+ row: 1,
1476
+ fillDomain: 0
1477
+ };
1478
+ }
1479
+ if (gridY.length > 0) {
1480
+ const uniqueYIntervals = new Map();
1481
+ gridY.forEach((interval)=>{
1482
+ const key = `${interval[0]}-${interval[1]}`;
1483
+ if (!uniqueYIntervals.has(key)) {
1484
+ uniqueYIntervals.set(key, interval);
1485
+ }
1486
+ });
1487
+ const minYInterval = Math.min(...Array.from(uniqueYIntervals.values()).map((interval)=>interval[1] - interval[0]));
1488
+ templateRows = Array.from(uniqueYIntervals.values()).map((interval)=>`${(interval[1] - interval[0]) / minYInterval}fr`).join(' ');
1489
+ gridY.forEach((interval, index)=>{
1490
+ if (interval.length === 0) {
1491
+ return;
1492
+ }
1493
+ const cellName = `x${index === 0 ? '' : index + 1}`;
1494
+ const annotationProps = annotations[index];
1495
+ const yAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.yAnnotation;
1496
+ const cell = gridLayout[cellName];
1497
+ if (cell !== undefined) {
1498
+ cell.row = columnFill[cell.column].row;
1499
+ cell.yAnnotation = yAnnotation;
1500
+ }
1501
+ columnFill[cell.column].fillDomain = interval[1];
1502
+ columnFill[cell.column].row += 1;
1503
+ });
1504
+ }
1505
+ // reverse the order of rows in grid layout from bottom-top to top-bottom as required by CSS grid
1506
+ const reversedGridLayout = {};
1507
+ // find the maximum row number
1508
+ const maxRowNumber = Math.max(...Object.values(gridLayout).map((cell)=>{
1509
+ var _cell_row;
1510
+ return (_cell_row = cell.row) !== null && _cell_row !== void 0 ? _cell_row : 0;
1511
+ }));
1512
+ // iterate over the gridLayout and reverse the row numbers
1513
+ Object.keys(gridLayout).forEach((key)=>{
1514
+ const cell = gridLayout[key];
1515
+ if (cell.row !== undefined) {
1516
+ // reverse the row number
1517
+ cell.row = maxRowNumber - cell.row + 1;
1518
+ }
1519
+ reversedGridLayout[key] = cell;
1520
+ });
1521
+ return {
1522
+ templateRows,
1523
+ templateColumns,
1524
+ layout: reversedGridLayout
1525
+ };
1526
+ };
1527
+ /**
1528
+ * @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/category_order_defaults.js#L50}
1529
+ */ const getAxisCategoryOrderProps = (data, layout)=>{
1530
+ const result = {};
1531
+ const axesById = {
1532
+ x: layout === null || layout === void 0 ? void 0 : layout.xaxis,
1533
+ y: layout === null || layout === void 0 ? void 0 : layout.yaxis
885
1534
  };
1535
+ Object.keys(axesById).forEach((axId)=>{
1536
+ const ax = axesById[axId];
1537
+ const axLetter = axId[0];
1538
+ const propName = `${axLetter}AxisCategoryOrder`;
1539
+ const values = [];
1540
+ data.forEach((series)=>{
1541
+ var _series_axLetter;
1542
+ (_series_axLetter = series[axLetter]) === null || _series_axLetter === void 0 ? void 0 : _series_axLetter.forEach((val)=>{
1543
+ if (!isInvalidValue(val)) {
1544
+ values.push(val);
1545
+ }
1546
+ });
1547
+ });
1548
+ const isAxisTypeCategory = (ax === null || ax === void 0 ? void 0 : ax.type) === 'category' || isStringArray(values) && !isNumberArray(values) && !isDateArray(values);
1549
+ if (!isAxisTypeCategory) {
1550
+ return;
1551
+ }
1552
+ const isValidArray = isArrayOrTypedArray(ax === null || ax === void 0 ? void 0 : ax.categoryarray) && ax.categoryarray.length > 0;
1553
+ if (isValidArray && (!(ax === null || ax === void 0 ? void 0 : ax.categoryorder) || ax.categoryorder === 'array')) {
1554
+ result[propName] = ax.categoryarray;
1555
+ return;
1556
+ }
1557
+ if (!(ax === null || ax === void 0 ? void 0 : ax.categoryorder) || ax.categoryorder === 'trace' || ax.categoryorder === 'array') {
1558
+ const categoriesInTraceOrder = Array.from(new Set(values));
1559
+ result[propName] = categoriesInTraceOrder;
1560
+ return;
1561
+ }
1562
+ result[propName] = ax.categoryorder;
1563
+ });
1564
+ return result;
886
1565
  };