@fluentui/react-charts 9.2.3 → 9.2.4

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 (194) hide show
  1. package/CHANGELOG.md +49 -10
  2. package/dist/index.d.ts +98 -5
  3. package/lib/components/AreaChart/AreaChart.js +3 -3
  4. package/lib/components/AreaChart/AreaChart.js.map +1 -1
  5. package/lib/components/AreaChart/useAreaChartStyles.styles.js +2 -2
  6. package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
  7. package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js +3 -15
  8. package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
  9. package/lib/components/ChartTable/ChartTable.js +89 -6
  10. package/lib/components/ChartTable/ChartTable.js.map +1 -1
  11. package/lib/components/CommonComponents/CartesianChart.js +38 -34
  12. package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
  13. package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
  14. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +17 -14
  15. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  16. package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +6 -33
  17. package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
  18. package/lib/components/DeclarativeChart/DeclarativeChart.js +55 -16
  19. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  20. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +19 -0
  21. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
  22. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +1058 -291
  23. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  24. package/lib/components/DonutChart/Arc/useArcStyles.styles.js +8 -3
  25. package/lib/components/DonutChart/Arc/useArcStyles.styles.js.map +1 -1
  26. package/lib/components/DonutChart/Arc/useArcStyles.styles.raw.js +6 -2
  27. package/lib/components/DonutChart/Arc/useArcStyles.styles.raw.js.map +1 -1
  28. package/lib/components/DonutChart/DonutChart.js +6 -1
  29. package/lib/components/DonutChart/DonutChart.js.map +1 -1
  30. package/lib/components/DonutChart/DonutChart.types.js.map +1 -1
  31. package/lib/components/DonutChart/useDonutChartStyles.styles.js +21 -4
  32. package/lib/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
  33. package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js +8 -4
  34. package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
  35. package/lib/components/FunnelChart/FunnelChart.js +4 -2
  36. package/lib/components/FunnelChart/FunnelChart.js.map +1 -1
  37. package/lib/components/FunnelChart/funnelGeometry.js.map +1 -1
  38. package/lib/components/GaugeChart/GaugeChart.js +1 -2
  39. package/lib/components/GaugeChart/GaugeChart.js.map +1 -1
  40. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +2 -2
  41. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  42. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +4 -17
  43. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  44. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +4 -21
  45. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
  46. package/lib/components/HorizontalBarChart/HorizontalBarChart.js +1 -1
  47. package/lib/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
  48. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +7 -3
  49. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
  50. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js +5 -2
  51. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js.map +1 -1
  52. package/lib/components/LineChart/LineChart.js +271 -271
  53. package/lib/components/LineChart/LineChart.js.map +1 -1
  54. package/lib/components/LineChart/LineChart.types.js.map +1 -1
  55. package/lib/components/LineChart/useLineChartStyles.styles.js +23 -10
  56. package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  57. package/lib/components/LineChart/useLineChartStyles.styles.raw.js +4 -21
  58. package/lib/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
  59. package/lib/components/ResponsiveContainer/withResponsiveContainer.js.map +1 -1
  60. package/lib/components/SankeyChart/SankeyChart.js.map +1 -1
  61. package/lib/components/SankeyChart/useSankeyChartStyles.styles.js +12 -25
  62. package/lib/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
  63. package/lib/components/SankeyChart/useSankeyChartStyles.styles.raw.js +2 -12
  64. package/lib/components/SankeyChart/useSankeyChartStyles.styles.raw.js.map +1 -1
  65. package/lib/components/ScatterChart/ScatterChart.js +114 -75
  66. package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
  67. package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -1
  68. package/lib/components/ScatterChart/useScatterChartStyles.styles.js +11 -7
  69. package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  70. package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js +4 -22
  71. package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
  72. package/lib/components/VerticalBarChart/VerticalBarChart.js +2 -2
  73. package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  74. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +8 -6
  75. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  76. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +5 -19
  77. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
  78. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +2 -2
  79. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  80. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +7 -6
  81. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
  82. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +4 -19
  83. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
  84. package/lib/types/DataPoint.js +3 -1
  85. package/lib/types/DataPoint.js.map +1 -1
  86. package/lib/utilities/Common.styles.js +47 -0
  87. package/lib/utilities/Common.styles.js.map +1 -0
  88. package/lib/utilities/Common.styles.raw.js +47 -0
  89. package/lib/utilities/Common.styles.raw.js.map +1 -0
  90. package/lib/utilities/SVGTooltipText.js.map +1 -1
  91. package/lib/utilities/image-export-utils.js.map +1 -1
  92. package/lib/utilities/index.js +1 -0
  93. package/lib/utilities/index.js.map +1 -1
  94. package/lib/utilities/scatterpolar-utils.js +52 -0
  95. package/lib/utilities/scatterpolar-utils.js.map +1 -0
  96. package/lib/utilities/utilities.js +309 -142
  97. package/lib/utilities/utilities.js.map +1 -1
  98. package/lib/utilities/vbc-utils.js.map +1 -1
  99. package/lib-commonjs/components/AreaChart/AreaChart.js +2 -2
  100. package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
  101. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
  102. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js +2 -14
  103. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
  104. package/lib-commonjs/components/ChartTable/ChartTable.js +89 -6
  105. package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -1
  106. package/lib-commonjs/components/CommonComponents/CartesianChart.js +38 -34
  107. package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
  108. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
  109. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +15 -13
  110. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  111. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +4 -32
  112. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
  113. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +58 -19
  114. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  115. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +22 -0
  116. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
  117. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +1070 -291
  118. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  119. package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.js +12 -3
  120. package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.js.map +1 -1
  121. package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.raw.js +6 -2
  122. package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.raw.js.map +1 -1
  123. package/lib-commonjs/components/DonutChart/DonutChart.js +6 -1
  124. package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
  125. package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -1
  126. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js +32 -4
  127. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
  128. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js +8 -4
  129. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
  130. package/lib-commonjs/components/FunnelChart/FunnelChart.js +4 -2
  131. package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -1
  132. package/lib-commonjs/components/FunnelChart/funnelGeometry.js.map +1 -1
  133. package/lib-commonjs/components/GaugeChart/GaugeChart.js +1 -2
  134. package/lib-commonjs/components/GaugeChart/GaugeChart.js.map +1 -1
  135. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +2 -2
  136. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  137. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +2 -19
  138. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  139. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +3 -20
  140. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
  141. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js +1 -1
  142. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
  143. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +10 -3
  144. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
  145. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js +5 -2
  146. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js.map +1 -1
  147. package/lib-commonjs/components/LineChart/LineChart.js +269 -269
  148. package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
  149. package/lib-commonjs/components/LineChart/LineChart.types.js.map +1 -1
  150. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js +30 -9
  151. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  152. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js +2 -20
  153. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
  154. package/lib-commonjs/components/ResponsiveContainer/withResponsiveContainer.js.map +1 -1
  155. package/lib-commonjs/components/SankeyChart/SankeyChart.js.map +1 -1
  156. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js +23 -33
  157. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
  158. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.raw.js +1 -12
  159. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.raw.js.map +1 -1
  160. package/lib-commonjs/components/ScatterChart/ScatterChart.js +112 -73
  161. package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
  162. package/lib-commonjs/components/ScatterChart/ScatterChart.types.js.map +1 -1
  163. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js +13 -7
  164. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  165. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js +2 -20
  166. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
  167. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +1 -1
  168. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  169. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +5 -3
  170. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  171. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +3 -17
  172. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
  173. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +1 -1
  174. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  175. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +5 -3
  176. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
  177. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +3 -18
  178. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
  179. package/lib-commonjs/types/DataPoint.js +3 -1
  180. package/lib-commonjs/types/DataPoint.js.map +1 -1
  181. package/lib-commonjs/utilities/Common.styles.js +71 -0
  182. package/lib-commonjs/utilities/Common.styles.js.map +1 -0
  183. package/lib-commonjs/utilities/Common.styles.raw.js +71 -0
  184. package/lib-commonjs/utilities/Common.styles.raw.js.map +1 -0
  185. package/lib-commonjs/utilities/SVGTooltipText.js.map +1 -1
  186. package/lib-commonjs/utilities/image-export-utils.js.map +1 -1
  187. package/lib-commonjs/utilities/index.js +1 -0
  188. package/lib-commonjs/utilities/index.js.map +1 -1
  189. package/lib-commonjs/utilities/scatterpolar-utils.js +67 -0
  190. package/lib-commonjs/utilities/scatterpolar-utils.js.map +1 -0
  191. package/lib-commonjs/utilities/utilities.js +322 -133
  192. package/lib-commonjs/utilities/utilities.js.map +1 -1
  193. package/lib-commonjs/utilities/vbc-utils.js.map +1 -1
  194. package/package.json +9 -9
@@ -3,11 +3,13 @@ import { bin as d3Bin, extent as d3Extent, sum as d3Sum, min as d3Min, max as d3
3
3
  import { scaleLinear as d3ScaleLinear } from 'd3-scale';
4
4
  import { format as d3Format } from 'd3-format';
5
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';
6
+ import { DEFAULT_DATE_STRING, findNumericMinMaxOfY, formatScientificLimitWidth, MIN_DONUT_RADIUS, calculatePrecision, precisionRound } from '../../utilities/utilities';
7
+ import { isArrayOrTypedArray, isDate, isDateArray, isNumberArray, isStringArray, isYearArray, isInvalidValue, formatToLocaleString, isNumber, isObjectArray, getAxisIds, getAxisKey } from '@fluentui/chart-utilities';
8
8
  import { curveCardinal as d3CurveCardinal } from 'd3-shape';
9
- import { getOpacity, extractColor, resolveColor } from './PlotlyColorAdapter';
9
+ import { getOpacity, extractColor, resolveColor, createColorScale } from './PlotlyColorAdapter';
10
10
  import { rgb } from 'd3-color';
11
+ export const NON_PLOT_KEY_PREFIX = 'nonplot_';
12
+ export const SINGLE_REPEAT = 'repeat(1, 1fr)';
11
13
  const dashOptions = {
12
14
  dot: {
13
15
  strokeDasharray: '1, 5',
@@ -56,6 +58,47 @@ function getTitles(layout) {
56
58
  };
57
59
  return titles;
58
60
  }
61
+ const getXAxisTickFormat = (series, layout)=>{
62
+ const xAxis = getXAxisProperties(series, layout);
63
+ if (xAxis === null || xAxis === void 0 ? void 0 : xAxis.tickformat) {
64
+ return {
65
+ tickFormat: xAxis === null || xAxis === void 0 ? void 0 : xAxis.tickformat
66
+ };
67
+ }
68
+ return {};
69
+ };
70
+ const getYAxisTickFormat = (series, layout)=>{
71
+ const yAxis = getYAxisProperties(series, layout);
72
+ if (yAxis === null || yAxis === void 0 ? void 0 : yAxis.tickformat) {
73
+ return {
74
+ yAxisTickFormat: d3Format(yAxis === null || yAxis === void 0 ? void 0 : yAxis.tickformat)
75
+ };
76
+ }
77
+ return {};
78
+ };
79
+ const getYMinMaxValues = (series, layout)=>{
80
+ var _getYAxisProperties;
81
+ const range = (_getYAxisProperties = getYAxisProperties(series, layout)) === null || _getYAxisProperties === void 0 ? void 0 : _getYAxisProperties.range;
82
+ if (range && range.length === 2) {
83
+ return {
84
+ yMinValue: range[0],
85
+ yMaxValue: range[1]
86
+ };
87
+ }
88
+ return {};
89
+ };
90
+ const getYAxisProperties = (series, layout)=>{
91
+ return layout === null || layout === void 0 ? void 0 : layout.yaxis;
92
+ };
93
+ const getXAxisProperties = (series, layout)=>{
94
+ return layout === null || layout === void 0 ? void 0 : layout.xaxis;
95
+ };
96
+ const getFormattedCalloutYData = (yVal, yAxisFormat)=>{
97
+ if (typeof (yAxisFormat === null || yAxisFormat === void 0 ? void 0 : yAxisFormat.yAxisTickFormat) === 'function' && typeof yVal === 'number') {
98
+ return yAxisFormat.yAxisTickFormat(yVal);
99
+ }
100
+ return formatToLocaleString(yVal);
101
+ };
59
102
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
60
103
  export const correctYearMonth = (xValues)=>{
61
104
  const presentYear = new Date().getFullYear();
@@ -155,8 +198,122 @@ export const resolveXAxisPoint = (x, isXYearCategory, isXString, isXDate, isXNum
155
198
  }
156
199
  return x;
157
200
  };
201
+ /**
202
+ * Checks if a key should be ignored during normalization
203
+ * @param key The key to check
204
+ * @returns true if the key should be ignored
205
+ */ const shouldIgnoreKey = (key)=>{
206
+ const lowerKey = key.toLowerCase();
207
+ if (lowerKey.includes('style') || lowerKey === 'style') {
208
+ return true;
209
+ }
210
+ // Use regex to match common CSS property patterns
211
+ // (color, fill, stroke, border, background, font, shadow, outline, etc.)
212
+ const cssKeyRegex = new RegExp('^(color|fill|stroke|border|background|font|shadow|outline|margin|padding|gap|align|justify|display|flex|grid|' + 'text|line|letter|word|vertical|horizontal|overflow|position|top|right|bottom|left|zindex|z-index|opacity|' + 'filter|clip|cursor|resize|transition|animation|transform|box|column|row|direction|visibility|' + 'content|width|height|aspect|image|user|pointer|caret|scroll|%)|(-webkit-|-moz-|-ms-|-o-)', 'i');
213
+ if (cssKeyRegex.test(lowerKey)) {
214
+ return true;
215
+ }
216
+ return false;
217
+ };
218
+ /**
219
+ * Flattens a nested object into a single level object with dot notation keys
220
+ * @param obj Object to flatten
221
+ * @param prefix Optional prefix for keys
222
+ * @returns Flattened object
223
+ */ const flattenObject = (obj, prefix = '')=>{
224
+ const flattened = {};
225
+ for(const key in obj){
226
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
227
+ const newKey = prefix ? `${prefix}.${key}` : key;
228
+ const value = obj[key];
229
+ if (typeof value === 'object' && value !== null && !Array.isArray(value) && !(value instanceof Date)) {
230
+ // Recursively flatten nested objects
231
+ Object.assign(flattened, flattenObject(value, newKey));
232
+ } else {
233
+ flattened[newKey] = value;
234
+ }
235
+ }
236
+ }
237
+ return flattened;
238
+ };
239
+ /**
240
+ * Normalizes an array of objects by flattening nested structures and creating grouped data
241
+ * Uses json_normalize approach with D3 color detection and filtering
242
+ * @param data Array of objects to normalize
243
+ * @returns Object containing traces for grouped vertical bar chart
244
+ */ export const normalizeObjectArrayForGVBC = (data, xLabels)=>{
245
+ if (!data || data.length === 0) {
246
+ return {
247
+ traces: [],
248
+ x: []
249
+ };
250
+ }
251
+ // Use provided xLabels if available, otherwise default to Item 1, Item 2, ...
252
+ const x = xLabels && xLabels.length === data.length ? xLabels : data.map((_, index)=>`Item ${index + 1}`);
253
+ // First, flatten all objects and collect all unique keys, excluding style keys
254
+ const flattenedObjects = data.map((item, index)=>{
255
+ if (typeof item === 'object' && item !== null) {
256
+ const flattened = flattenObject(item);
257
+ // Only keep keys where the value is numeric (number or numeric string) and not a style key
258
+ const filtered = {};
259
+ Object.keys(flattened).forEach((key)=>{
260
+ const value = flattened[key];
261
+ if (!shouldIgnoreKey(key) && (typeof value === 'number' || typeof value === 'string' && isNumber(value))) {
262
+ filtered[key] = value;
263
+ }
264
+ });
265
+ return filtered;
266
+ } else if (typeof item === 'number' || typeof item === 'string' && isNumber(item)) {
267
+ // Only keep primitive numeric values
268
+ return {
269
+ [x[index] || `item_${index}`]: item
270
+ };
271
+ } else {
272
+ // Non-numeric primitive, ignore by returning empty object
273
+ return {};
274
+ }
275
+ });
276
+ // Collect all unique keys across all objects
277
+ const allKeys = new Set();
278
+ flattenedObjects.forEach((obj)=>{
279
+ Object.keys(obj).forEach((key)=>allKeys.add(key));
280
+ });
281
+ // Create traces for each key (property)
282
+ const traces = [];
283
+ allKeys.forEach((key)=>{
284
+ const yValues = [];
285
+ let hasValidData = false;
286
+ let isNumericData = false;
287
+ flattenedObjects.forEach((obj, index)=>{
288
+ const value = obj[key];
289
+ if (typeof value === 'number') {
290
+ yValues.push(value);
291
+ hasValidData = true;
292
+ isNumericData = true;
293
+ } else if (typeof value === 'string' && isNumber(value)) {
294
+ yValues.push(parseFloat(value));
295
+ hasValidData = true;
296
+ isNumericData = true;
297
+ }
298
+ });
299
+ // Only create trace if we have valid numeric data
300
+ if (hasValidData && isNumericData) {
301
+ const trace = {
302
+ type: 'bar',
303
+ name: key,
304
+ x,
305
+ y: yValues
306
+ };
307
+ traces.push(trace);
308
+ }
309
+ });
310
+ return {
311
+ traces,
312
+ x
313
+ };
314
+ };
158
315
  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;
316
+ var _input_layout, _input_layout_template_layout, _input_layout_template, _input_layout1, _input_layout2, _firstData_marker, _input_layout3, _input_layout4, _input_layout5, _input_layout6;
160
317
  const firstData = input.data[0];
161
318
  var _input_layout_piecolorway, _input_layout_piecolorway1;
162
319
  // extract colors for each series only once
@@ -164,24 +321,53 @@ export const transformPlotlyJsonToDonutProps = (input, isMultiPlot, colorMap, co
164
321
  // otherwise, default to colorway from template
165
322
  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);
166
323
  const mapLegendToDataPoint = {};
167
- (_firstData_labels = firstData.labels) === null || _firstData_labels === void 0 ? void 0 : _firstData_labels.forEach((label, index)=>{
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,
178
- data: value,
179
- color
180
- };
181
- } else {
182
- mapLegendToDataPoint[legend].data += value;
324
+ if (colors) {
325
+ var _firstData_labels;
326
+ (_firstData_labels = firstData.labels) === null || _firstData_labels === void 0 ? void 0 : _firstData_labels.forEach((label, index)=>{
327
+ const value = getNumberAtIndexOrDefault(firstData.values, index);
328
+ if (isInvalidValue(value) || value < 0) {
329
+ return;
330
+ }
331
+ const legend = `${label}`;
332
+ // resolve color for each legend from the extracted colors
333
+ const color = resolveColor(colors, index, legend, colorMap, isDarkTheme);
334
+ if (!mapLegendToDataPoint[legend]) {
335
+ mapLegendToDataPoint[legend] = {
336
+ legend,
337
+ data: value,
338
+ color
339
+ };
340
+ } else {
341
+ mapLegendToDataPoint[legend].data += value;
342
+ }
343
+ });
344
+ } else {
345
+ // Sort labels by value descending before mapping
346
+ if (firstData.labels && firstData.values) {
347
+ const labelValuePairs = firstData.labels.map((label, index)=>({
348
+ label,
349
+ value: getNumberAtIndexOrDefault(firstData.values, index),
350
+ index
351
+ }));
352
+ // Filter out invalid values
353
+ const validPairs = labelValuePairs.filter((pair)=>!isInvalidValue(pair.value));
354
+ // Sort descending by value
355
+ validPairs.sort((a, b)=>b.value - a.value);
356
+ validPairs.forEach((pair, sortedIdx)=>{
357
+ const legend = `${pair.label}`;
358
+ const color = resolveColor(colors, sortedIdx, legend, colorMap, isDarkTheme);
359
+ if (!mapLegendToDataPoint[legend]) {
360
+ mapLegendToDataPoint[legend] = {
361
+ legend,
362
+ data: pair.value,
363
+ color
364
+ };
365
+ } else {
366
+ mapLegendToDataPoint[legend].data += pair.value;
367
+ }
368
+ });
183
369
  }
184
- });
370
+ }
185
371
  var _input_layout_width;
186
372
  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;
187
373
  var _input_layout_height;
@@ -200,7 +386,7 @@ export const transformPlotlyJsonToDonutProps = (input, isMultiPlot, colorMap, co
200
386
  chartTitle,
201
387
  chartData: Object.values(mapLegendToDataPoint)
202
388
  },
203
- hideLegend: ((_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : _input_layout5.showlegend) === false ? true : false,
389
+ hideLegend: isMultiPlot || ((_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : _input_layout5.showlegend) === false,
204
390
  width: (_input_layout6 = input.layout) === null || _input_layout6 === void 0 ? void 0 : _input_layout6.width,
205
391
  height,
206
392
  innerRadius,
@@ -219,17 +405,16 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
219
405
  const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
220
406
  const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
221
407
  let colorScale = undefined;
408
+ const yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
222
409
  let yMinValue = 0;
223
410
  input.data.forEach((series, index1)=>{
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
- }
411
+ var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _input_layout_template_layout1, _input_layout_template1, _input_layout1, _series_line;
412
+ colorScale = createColorScale(input.layout, series, colorScale);
228
413
  const isXYearCategory = isYearArray(series.x); // Consider year as categorical not numeric continuous axis
229
414
  // 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);
415
+ const extractedBarColors = extractColor((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color, colorMap, isDarkTheme);
231
416
  // 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);
417
+ const extractedLineColors = extractColor((_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_template1 = _input_layout1.template) === null || _input_layout_template1 === void 0 ? void 0 : (_input_layout_template_layout1 = _input_layout_template1.layout) === null || _input_layout_template_layout1 === void 0 ? void 0 : _input_layout_template_layout1.colorway, colorwayType, (_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.color, colorMap, isDarkTheme);
233
418
  const xValues = series.x;
234
419
  const isXDate = isDateArray(xValues);
235
420
  const isXString = isStringArray(xValues);
@@ -252,6 +437,7 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
252
437
  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
438
  const opacity = getOpacity(series, index2);
254
439
  const yVal = rangeYValues[index2];
440
+ const yAxisCalloutData = getFormattedCalloutYData(yVal, yAxisTickFormat);
255
441
  if (series.type === 'bar') {
256
442
  var _rgb_copy_formatHex8;
257
443
  mapXToDataPoints[x].chartData.push({
@@ -259,7 +445,8 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
259
445
  data: yVal,
260
446
  color: (_rgb_copy_formatHex8 = rgb(color).copy({
261
447
  opacity
262
- }).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
448
+ }).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
449
+ yAxisCalloutData
263
450
  });
264
451
  if (typeof yVal === 'number') {
265
452
  yMaxValue = Math.max(yMaxValue, yVal);
@@ -281,7 +468,8 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
281
468
  ...lineOptions !== null && lineOptions !== void 0 ? lineOptions : {},
282
469
  mode: series.mode
283
470
  },
284
- useSecondaryYScale: usesSecondaryYScale(series, input.layout)
471
+ useSecondaryYScale: usesSecondaryYScale(series, input.layout),
472
+ yAxisCalloutData
285
473
  });
286
474
  if (!usesSecondaryYScale(series, input.layout) && typeof yVal === 'number') {
287
475
  yMaxValue = Math.max(yMaxValue, yVal);
@@ -292,7 +480,6 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
292
480
  });
293
481
  });
294
482
  });
295
- const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
296
483
  const vsbcData = Object.values(mapXToDataPoints);
297
484
  var _input_layout_height;
298
485
  return {
@@ -302,9 +489,6 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
302
489
  barWidth: 'auto',
303
490
  yMaxValue,
304
491
  yMinValue,
305
- chartTitle,
306
- xAxisTitle,
307
- yAxisTitle,
308
492
  mode: 'plotly',
309
493
  ...secondaryYAxisValues,
310
494
  wrapXAxisLables: typeof ((_vsbcData_ = vsbcData[0]) === null || _vsbcData_ === void 0 ? void 0 : _vsbcData_.xAxisPoint) === 'string',
@@ -315,36 +499,55 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
315
499
  showYAxisLables: true,
316
500
  noOfCharsToTruncate: 20,
317
501
  showYAxisLablesTooltip: true,
318
- ...getAxisCategoryOrderProps(input.data, input.layout)
502
+ ...getTitles(input.layout),
503
+ ...getXAxisTickFormat(input.data[0], input.layout),
504
+ ...yAxisTickFormat,
505
+ ...getAxisCategoryOrderProps(input.data, input.layout),
506
+ ...getBarProps(input.data, input.layout),
507
+ ...getYMinMaxValues(input.data[0], input.layout),
508
+ ...getAxisTickProps(input.data, input.layout)
319
509
  };
320
510
  };
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
511
  export const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
336
- var _input_layout, _input_layout1, _gvbcData_;
512
+ var _processedInput_layout, _processedInput_layout1, _gvbcData_;
513
+ // Handle object arrays in y values by normalizing the data first
514
+ let processedInput = {
515
+ ...input
516
+ };
517
+ // Check if any bar traces have object arrays as y values
518
+ const hasObjectArrayData = input.data.some((series)=>series.type === 'bar' && isObjectArray(series.y));
519
+ if (hasObjectArrayData) {
520
+ // Process each trace that has object array y values
521
+ const processedData = input.data.map((series, index)=>{
522
+ if (series.type === 'bar' && isObjectArray(series.y)) {
523
+ // Normalize the object array to create multiple traces for GVBC
524
+ const { traces } = normalizeObjectArrayForGVBC(series.y, Array.isArray(series.x) ? series.x : undefined);
525
+ // Return all the new traces, each representing a property from the objects
526
+ return traces.map((trace)=>({
527
+ ...trace,
528
+ // Copy other properties from the original series if needed
529
+ marker: series.marker
530
+ }));
531
+ }
532
+ return [
533
+ series
534
+ ];
535
+ }).flat();
536
+ processedInput = {
537
+ ...input,
538
+ data: processedData
539
+ };
540
+ }
337
541
  const mapXToDataPoints = {};
338
- const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, 0, 0);
339
- const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
542
+ const secondaryYAxisValues = getSecondaryYAxisValues(processedInput.data, processedInput.layout, 0, 0);
543
+ const { legends, hideLegend } = getLegendProps(processedInput.data, processedInput.layout, isMultiPlot);
340
544
  let colorScale = undefined;
341
- input.data.forEach((series, index1)=>{
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
- }
545
+ const yAxisTickFormat = getYAxisTickFormat(processedInput.data[0], processedInput.layout);
546
+ processedInput.data.forEach((series, index1)=>{
547
+ var _processedInput_layout_template_layout, _processedInput_layout_template, _processedInput_layout, _series_marker, _series_x;
548
+ colorScale = createColorScale(processedInput.layout, series, colorScale);
346
549
  // 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);
550
+ const extractedColors = extractColor((_processedInput_layout = processedInput.layout) === null || _processedInput_layout === void 0 ? void 0 : (_processedInput_layout_template = _processedInput_layout.template) === null || _processedInput_layout_template === void 0 ? void 0 : (_processedInput_layout_template_layout = _processedInput_layout_template.layout) === null || _processedInput_layout_template_layout === void 0 ? void 0 : _processedInput_layout_template_layout.colorway, colorwayType, (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color, colorMap, isDarkTheme);
348
551
  (_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x.forEach((x, index2)=>{
349
552
  var _series_y;
350
553
  if (isInvalidValue(x) || isInvalidValue((_series_y = series.y) === null || _series_y === void 0 ? void 0 : _series_y[index2])) {
@@ -362,38 +565,42 @@ export const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, col
362
565
  // resolve color for each legend's bars from the colorscale or extracted colors
363
566
  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
567
  const opacity = getOpacity(series, index2);
568
+ const yVal = series.y[index2];
365
569
  var _rgb_copy_formatHex8;
366
570
  mapXToDataPoints[x].series.push({
367
571
  key: legend,
368
- data: series.y[index2],
572
+ data: yVal,
369
573
  xAxisCalloutData: x,
370
574
  color: (_rgb_copy_formatHex8 = rgb(color).copy({
371
575
  opacity
372
576
  }).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
373
577
  legend,
374
- useSecondaryYScale: usesSecondaryYScale(series, input.layout)
578
+ useSecondaryYScale: usesSecondaryYScale(series, processedInput.layout),
579
+ yAxisCalloutData: getFormattedCalloutYData(yVal, yAxisTickFormat)
375
580
  });
376
581
  }
377
582
  });
378
583
  });
379
- const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
380
584
  const gvbcData = Object.values(mapXToDataPoints);
381
- var _input_layout_height;
585
+ var _processedInput_layout_height;
382
586
  return {
383
587
  data: gvbcData,
384
- width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
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,
588
+ width: (_processedInput_layout = processedInput.layout) === null || _processedInput_layout === void 0 ? void 0 : _processedInput_layout.width,
589
+ height: (_processedInput_layout_height = (_processedInput_layout1 = processedInput.layout) === null || _processedInput_layout1 === void 0 ? void 0 : _processedInput_layout1.height) !== null && _processedInput_layout_height !== void 0 ? _processedInput_layout_height : 350,
386
590
  barWidth: 'auto',
387
- chartTitle,
388
- xAxisTitle,
389
- yAxisTitle,
390
591
  mode: 'plotly',
391
592
  ...secondaryYAxisValues,
392
593
  hideTickOverlap: true,
393
594
  wrapXAxisLables: typeof ((_gvbcData_ = gvbcData[0]) === null || _gvbcData_ === void 0 ? void 0 : _gvbcData_.name) === 'string',
394
595
  hideLegend,
395
596
  roundCorners: true,
396
- ...getAxisCategoryOrderProps(input.data, input.layout)
597
+ ...getTitles(processedInput.layout),
598
+ ...getAxisCategoryOrderProps(processedInput.data, processedInput.layout),
599
+ ...getYMinMaxValues(processedInput.data[0], processedInput.layout),
600
+ ...getXAxisTickFormat(processedInput.data[0], processedInput.layout),
601
+ ...yAxisTickFormat,
602
+ ...getBarProps(processedInput.data, processedInput.layout),
603
+ ...getAxisTickProps(processedInput.data, processedInput.layout)
397
604
  };
398
605
  };
399
606
  export const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
@@ -402,15 +609,13 @@ export const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colo
402
609
  const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
403
610
  let colorScale = undefined;
404
611
  input.data.forEach((series, seriesIdx)=>{
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;
612
+ var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _series_xbins, _series_xbins1, _series_xbins2;
406
613
  if (!series.x) {
407
614
  return;
408
615
  }
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
- }
616
+ colorScale = createColorScale(input.layout, series, colorScale);
412
617
  // 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);
618
+ const extractedColors = extractColor((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color, colorMap, isDarkTheme);
414
619
  const xValues = [];
415
620
  const yValues = [];
416
621
  series.x.forEach((xVal, index)=>{
@@ -459,21 +664,19 @@ export const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colo
459
664
  });
460
665
  });
461
666
  });
462
- const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
463
667
  var _input_layout_height;
464
668
  return {
465
669
  data: vbcData,
466
670
  width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
467
671
  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,
468
- chartTitle,
469
- xAxisTitle,
470
- yAxisTitle,
471
672
  mode: 'histogram',
472
673
  hideTickOverlap: true,
473
674
  wrapXAxisLables: typeof ((_vbcData_ = vbcData[0]) === null || _vbcData_ === void 0 ? void 0 : _vbcData_.x) === 'string',
474
675
  maxBarWidth: 50,
475
676
  hideLegend,
476
677
  roundCorners: true,
678
+ ...getTitles(input.layout),
679
+ ...getYMinMaxValues(input.data[0], input.layout),
477
680
  ...getAxisCategoryOrderProps(input.data, input.layout)
478
681
  };
479
682
  };
@@ -487,20 +690,23 @@ export const transformPlotlyJsonToScatterChartProps = (input, isMultiPlot, color
487
690
  return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'scatter', colorMap, colorwayType, isDarkTheme);
488
691
  };
489
692
  const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme)=>{
490
- var _input_data_;
693
+ var _input_data_, _input_layout, _input_layout1;
491
694
  const isScatterMarkers = [
695
+ 'text',
492
696
  'markers',
493
697
  'text+markers',
494
698
  'markers+text',
495
699
  'lines+markers',
496
700
  'markers+line',
497
- 'text+lines+markers'
701
+ 'text+lines+markers',
702
+ 'lines+markers+text'
498
703
  ].includes((_input_data_ = input.data[0]) === null || _input_data_ === void 0 ? void 0 : _input_data_.mode);
499
704
  const isAreaChart = chartType === 'area';
500
705
  const isScatterChart = chartType === 'scatter';
501
706
  const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
502
707
  let mode = 'tonexty';
503
708
  const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
709
+ const yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
504
710
  const chartData = input.data.map((series, index)=>{
505
711
  var _series_mode, _series_line, _series_marker, _series_line1, _input_layout_template_layout, _input_layout_template, _input_layout, _series_mode1;
506
712
  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;
@@ -516,11 +722,12 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
516
722
  const seriesColor = resolveColor(extractedColors, index, legend, colorMap, isDarkTheme);
517
723
  const seriesOpacity = getOpacity(series, index);
518
724
  mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
519
- const lineOptions = !((_series_mode1 = series.mode) === null || _series_mode1 === void 0 ? void 0 : _series_mode1.includes('text')) ? getLineOptions(series.line) : undefined;
725
+ // if mode contains 'text', we prioritize showing the text over curving the line
726
+ const lineOptions = !((_series_mode1 = series.mode) === null || _series_mode1 === void 0 ? void 0 : _series_mode1.includes('text')) && series.type !== 'scatterpolar' ? getLineOptions(series.line) : undefined;
520
727
  const legendShape = getLegendShape(series);
521
728
  const validXYRanges = getValidXYRanges(series);
522
729
  return validXYRanges.map(([rangeStart, rangeEnd], rangeIdx)=>{
523
- var _series_marker;
730
+ var _series_marker, _input_layout, _input_layout_polar_angularaxis, _input_layout_polar, _input_layout1, _input_layout_polar_angularaxis1, _input_layout_polar1, _input_layout2;
524
731
  const rangeXValues = xValues.slice(rangeStart, rangeEnd);
525
732
  const rangeYValues = series.y.slice(rangeStart, rangeEnd);
526
733
  const markerSizes = isArrayOrTypedArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.size) ? series.marker.size.slice(rangeStart, rangeEnd) : [];
@@ -541,7 +748,8 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
541
748
  } : {},
542
749
  ...textValues ? {
543
750
  text: textValues[i]
544
- } : {}
751
+ } : {},
752
+ yAxisCalloutData: getFormattedCalloutYData(rangeYValues[i], yAxisTickFormat)
545
753
  };
546
754
  }),
547
755
  color: (_rgb_copy_formatHex8 = rgb(seriesColor).copy({
@@ -549,58 +757,65 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
549
757
  }).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : seriesColor,
550
758
  lineOptions: {
551
759
  ...lineOptions !== null && lineOptions !== void 0 ? lineOptions : {},
552
- mode: series.mode
760
+ mode: series.type !== 'scatterpolar' ? series.mode : 'scatterpolar',
761
+ // originXOffset is not typed on Layout, but may be present in input.layout as a part of projection of
762
+ // scatter polar coordingates to cartesian coordinates
763
+ ...series.type === 'scatterpolar' ? {
764
+ originXOffset: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.__polarOriginX,
765
+ direction: (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_polar = _input_layout1.polar) === null || _input_layout_polar === void 0 ? void 0 : (_input_layout_polar_angularaxis = _input_layout_polar.angularaxis) === null || _input_layout_polar_angularaxis === void 0 ? void 0 : _input_layout_polar_angularaxis.direction,
766
+ rotation: (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : (_input_layout_polar1 = _input_layout2.polar) === null || _input_layout_polar1 === void 0 ? void 0 : (_input_layout_polar_angularaxis1 = _input_layout_polar1.angularaxis) === null || _input_layout_polar_angularaxis1 === void 0 ? void 0 : _input_layout_polar_angularaxis1.rotation,
767
+ axisLabel: series.__axisLabel ? series.__axisLabel : {}
768
+ } : {}
553
769
  },
554
770
  useSecondaryYScale: usesSecondaryYScale(series, input.layout)
555
771
  };
556
772
  });
557
773
  }).flat();
558
- const yMinMaxValues = findNumericMinMaxOfY(chartData);
559
- const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
774
+ const yMinMax = getYMinMaxValues(input.data[0], input.layout);
775
+ if (yMinMax.yMinValue === undefined && yMinMax.yMaxValue === undefined) {
776
+ const yMinMaxValues = findNumericMinMaxOfY(chartData);
777
+ yMinMax.yMinValue = yMinMaxValues.startValue;
778
+ yMinMax.yMaxValue = yMinMaxValues.endValue;
779
+ }
560
780
  const numDataPoints = chartData.reduce((total, lineChartPoints)=>total + lineChartPoints.data.length, 0);
561
781
  const chartProps = {
562
- chartTitle,
563
782
  lineChartData: chartData
564
783
  };
565
784
  const scatterChartProps = {
566
- chartTitle,
567
785
  scatterChartData: chartData
568
786
  };
787
+ var _input_layout_height;
788
+ const commonProps = {
789
+ supportNegativeData: true,
790
+ ...secondaryYAxisValues,
791
+ width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
792
+ 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
+ hideTickOverlap: true,
794
+ hideLegend,
795
+ useUTC: false,
796
+ optimizeLargeData: numDataPoints > 1000,
797
+ ...getTitles(input.layout),
798
+ ...getXAxisTickFormat(input.data[0], input.layout),
799
+ ...yAxisTickFormat,
800
+ ...getAxisScaleTypeProps(input.data, input.layout),
801
+ ...getAxisTickProps(input.data, input.layout)
802
+ };
569
803
  if (isAreaChart) {
570
- var _input_layout, _input_layout1;
571
- var _input_layout_height;
572
804
  return {
573
805
  data: chartProps,
574
- supportNegativeData: true,
575
- xAxisTitle,
576
- yAxisTitle,
577
- ...secondaryYAxisValues,
578
806
  mode,
579
- width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
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,
581
- hideTickOverlap: true,
582
- useUTC: false,
583
- hideLegend,
584
- optimizeLargeData: numDataPoints > 1000
807
+ ...commonProps
585
808
  };
586
809
  } else {
587
- var _input_layout2, _input_layout3;
588
- var _input_layout_height1;
589
810
  return {
590
811
  data: isScatterChart ? scatterChartProps : chartProps,
591
- supportNegativeData: true,
592
- xAxisTitle,
593
- yAxisTitle,
594
- ...secondaryYAxisValues,
595
812
  roundedTicks: true,
596
- yMinValue: yMinMaxValues.startValue,
597
- yMaxValue: yMinMaxValues.endValue,
598
- width: (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.width,
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,
600
- hideTickOverlap: true,
601
- useUTC: false,
602
- hideLegend,
603
- optimizeLargeData: numDataPoints > 1000
813
+ ...commonProps,
814
+ ...yMinMax,
815
+ ...isScatterChart ? {
816
+ showYAxisLablesTooltip: true,
817
+ ...getAxisCategoryOrderProps(input.data, input.layout)
818
+ } : {}
604
819
  };
605
820
  }
606
821
  };
@@ -609,12 +824,10 @@ export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPl
609
824
  const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
610
825
  let colorScale = undefined;
611
826
  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
- }
827
+ var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker;
828
+ colorScale = createColorScale(input.layout, series, colorScale);
616
829
  // 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);
830
+ const extractedColors = extractColor((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color, colorMap, isDarkTheme);
618
831
  const legend = legends[index];
619
832
  return series.y.map((yValue, i)=>{
620
833
  var _series_x, _series_marker, _series_marker1, _series_marker_color, _series_marker2;
@@ -646,12 +859,8 @@ export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPl
646
859
  const scalingFactor = 0.01;
647
860
  const gapFactor = 1 / (1 + scalingFactor * numberOfRows);
648
861
  const barHeight = availableHeight / (numberOfRows * (1 + gapFactor));
649
- const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
650
862
  return {
651
863
  data: chartData,
652
- chartTitle,
653
- xAxisTitle,
654
- yAxisTitle,
655
864
  secondaryYAxistitle: typeof ((_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : (_input_layout_yaxis2 = _input_layout3.yaxis2) === null || _input_layout_yaxis2 === void 0 ? void 0 : _input_layout_yaxis2.title) === 'string' ? (_input_layout4 = input.layout) === null || _input_layout4 === void 0 ? void 0 : (_input_layout_yaxis21 = _input_layout4.yaxis2) === null || _input_layout_yaxis21 === void 0 ? void 0 : _input_layout_yaxis21.title : ((_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : (_input_layout_yaxis22 = _input_layout5.yaxis2) === null || _input_layout_yaxis22 === void 0 ? void 0 : (_input_layout_yaxis2_title = _input_layout_yaxis22.title) === null || _input_layout_yaxis2_title === void 0 ? void 0 : _input_layout_yaxis2_title.text) || '',
656
865
  barHeight,
657
866
  showYAxisLables: true,
@@ -662,7 +871,67 @@ export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPl
662
871
  showYAxisLablesTooltip: true,
663
872
  hideLegend,
664
873
  roundCorners: true,
665
- ...getAxisCategoryOrderProps(input.data, input.layout)
874
+ ...getTitles(input.layout),
875
+ ...getAxisCategoryOrderProps(input.data, input.layout),
876
+ ...getBarProps(input.data, input.layout, true),
877
+ ...getAxisTickProps(input.data, input.layout)
878
+ };
879
+ };
880
+ export const transformPlotlyJsonToGanttChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
881
+ var _input_layout, _input_layout1;
882
+ const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
883
+ let colorScale = undefined;
884
+ const chartData = input.data.map((series, index)=>{
885
+ var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _input_layout_xaxis, _input_layout1;
886
+ colorScale = createColorScale(input.layout, series, colorScale);
887
+ // extract colors for each series only once
888
+ const extractedColors = extractColor((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color, colorMap, isDarkTheme);
889
+ const legend = legends[index];
890
+ const isXDate = ((_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_xaxis = _input_layout1.xaxis) === null || _input_layout_xaxis === void 0 ? void 0 : _input_layout_xaxis.type) === 'date' || isDateArray(series.x);
891
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
892
+ const convertXValueToNumber = (value)=>{
893
+ return isInvalidValue(value) ? 0 : isXDate ? +parseLocalDate(value) : +value;
894
+ };
895
+ return series.y.map((yVal, i)=>{
896
+ var _series_marker, _series_marker1, _series_marker_color, _series_marker2, _series_base, _series_x;
897
+ if (isInvalidValue(yVal)) {
898
+ return null;
899
+ }
900
+ // resolve color for each legend's bars from the colorscale or extracted colors
901
+ 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);
902
+ const opacity = getOpacity(series, i);
903
+ const base = convertXValueToNumber((_series_base = series.base) === null || _series_base === void 0 ? void 0 : _series_base[i]);
904
+ const xVal = convertXValueToNumber((_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x[i]);
905
+ var _rgb_copy_formatHex8;
906
+ return {
907
+ x: {
908
+ start: isXDate ? new Date(base) : base,
909
+ end: isXDate ? new Date(base + xVal) : base + xVal
910
+ },
911
+ y: yVal,
912
+ legend,
913
+ color: (_rgb_copy_formatHex8 = rgb(color).copy({
914
+ opacity
915
+ }).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
916
+ };
917
+ }).filter((point)=>point !== null);
918
+ }).flat();
919
+ var _input_layout_height;
920
+ return {
921
+ data: chartData,
922
+ showYAxisLables: true,
923
+ height: (_input_layout_height = (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
924
+ width: (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.width,
925
+ hideTickOverlap: true,
926
+ hideLegend,
927
+ noOfCharsToTruncate: 20,
928
+ showYAxisLablesTooltip: true,
929
+ roundCorners: true,
930
+ useUTC: false,
931
+ ...getTitles(input.layout),
932
+ ...getAxisCategoryOrderProps(input.data, input.layout),
933
+ ...getBarProps(input.data, input.layout, true),
934
+ ...getAxisTickProps(input.data, input.layout)
666
935
  };
667
936
  };
668
937
  export const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
@@ -776,7 +1045,6 @@ export const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap,
776
1045
  }
777
1046
  const domainValuesForColorScale = Array.isArray(colorscale) ? colorscale.map((arr)=>arr[0] * (zMax - zMin) + zMin) : defaultDomain;
778
1047
  const rangeValuesForColorScale = Array.isArray(colorscale) ? colorscale.map((arr)=>arr[1]) : defaultRange;
779
- const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
780
1048
  var _input_layout_height;
781
1049
  return {
782
1050
  data: [
@@ -786,9 +1054,6 @@ export const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap,
786
1054
  rangeValuesForColorScale,
787
1055
  hideLegend: true,
788
1056
  showYAxisLables: true,
789
- chartTitle,
790
- xAxisTitle,
791
- yAxisTitle,
792
1057
  sortOrder: 'none',
793
1058
  width: (_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : _input_layout5.width,
794
1059
  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,
@@ -796,9 +1061,11 @@ export const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap,
796
1061
  noOfCharsToTruncate: 20,
797
1062
  showYAxisLablesTooltip: true,
798
1063
  wrapXAxisLables: true,
1064
+ ...getTitles(input.layout),
799
1065
  ...getAxisCategoryOrderProps([
800
1066
  firstData
801
- ], input.layout)
1067
+ ], input.layout),
1068
+ ...getAxisTickProps(input.data, input.layout)
802
1069
  };
803
1070
  };
804
1071
  export const transformPlotlyJsonToSankeyProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
@@ -947,7 +1214,7 @@ const formatValue = (value, colIndex, cells)=>{
947
1214
  return `${prefix !== null && prefix !== void 0 ? prefix : ''}${formatted}${suffix !== null && suffix !== void 0 ? suffix : ''}`;
948
1215
  };
949
1216
  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;
1217
+ var _tableData_cells, _input_layout_template_data_table_, _input_layout_template_data_table, _input_layout_template_data, _input_layout_template, _input_layout, _input_layout_font, _input_layout1, _tableData_header, _input_layout_template_data1, _input_layout_template1, _input_layout2, _input_layout3, _input_layout4;
951
1218
  const tableData = input.data[0];
952
1219
  const normalizeHeaders = (values, header)=>{
953
1220
  const cleanedValues = Array.isArray(values[0]) ? values.map((row)=>row.map((cell)=>cleanText(cell)).filter(Boolean).join(' ')) : values.map((cell)=>cleanText(cell));
@@ -956,7 +1223,8 @@ export const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMa
956
1223
  const fontColorRaw = header === null || header === void 0 ? void 0 : (_header_font = header.font) === null || _header_font === void 0 ? void 0 : _header_font.color;
957
1224
  let fontColor;
958
1225
  if (Array.isArray(fontColorRaw)) {
959
- const colorEntry = fontColorRaw[colIndex];
1226
+ var _fontColorRaw_colIndex;
1227
+ const colorEntry = (_fontColorRaw_colIndex = fontColorRaw[colIndex]) !== null && _fontColorRaw_colIndex !== void 0 ? _fontColorRaw_colIndex : fontColorRaw[0];
960
1228
  if (Array.isArray(colorEntry)) {
961
1229
  fontColor = typeof colorEntry[0] === 'string' ? colorEntry[0] : undefined;
962
1230
  } else if (typeof colorEntry === 'string') {
@@ -968,15 +1236,20 @@ export const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMa
968
1236
  const fontSizeRaw = header === null || header === void 0 ? void 0 : (_header_font1 = header.font) === null || _header_font1 === void 0 ? void 0 : _header_font1.size;
969
1237
  let fontSize;
970
1238
  if (Array.isArray(fontSizeRaw)) {
971
- fontSize = Array.isArray(fontSizeRaw[0]) ? fontSizeRaw[0][colIndex] : fontSizeRaw[colIndex];
1239
+ var _fontSizeRaw_colIndex;
1240
+ const fontSizeEntry = (_fontSizeRaw_colIndex = fontSizeRaw[colIndex]) !== null && _fontSizeRaw_colIndex !== void 0 ? _fontSizeRaw_colIndex : fontSizeRaw[0];
1241
+ var _fontSizeRaw__colIndex;
1242
+ fontSize = Array.isArray(fontSizeRaw[0]) ? (_fontSizeRaw__colIndex = fontSizeRaw[0][colIndex]) !== null && _fontSizeRaw__colIndex !== void 0 ? _fontSizeRaw__colIndex : fontSizeRaw[0][0] : typeof fontSizeEntry === 'number' ? fontSizeEntry : undefined;
972
1243
  } else if (typeof fontSizeRaw === 'number') {
973
1244
  fontSize = fontSizeRaw;
974
1245
  }
975
1246
  const updatedColIndex = colIndex >= 1 ? 1 : 0;
976
1247
  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;
1248
+ var _fillColorRaw_updatedColIndex;
1249
+ const backgroundColor = Array.isArray(fillColorRaw) ? (_fillColorRaw_updatedColIndex = fillColorRaw[updatedColIndex]) !== null && _fillColorRaw_updatedColIndex !== void 0 ? _fillColorRaw_updatedColIndex : fillColorRaw[0] : fillColorRaw;
978
1250
  const textAlignRaw = header === null || header === void 0 ? void 0 : header.align;
979
- const textAlign = Array.isArray(textAlignRaw) ? textAlignRaw[colIndex] : textAlignRaw;
1251
+ var _textAlignRaw_colIndex;
1252
+ const textAlign = Array.isArray(textAlignRaw) ? (_textAlignRaw_colIndex = textAlignRaw[colIndex]) !== null && _textAlignRaw_colIndex !== void 0 ? _textAlignRaw_colIndex : textAlignRaw[0] : textAlignRaw;
980
1253
  const style = {
981
1254
  ...typeof fontColor === 'string' ? {
982
1255
  color: fontColor
@@ -999,7 +1272,7 @@ export const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMa
999
1272
  };
1000
1273
  var _tableData_cells_values;
1001
1274
  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;
1275
+ const cells = tableData.cells && Object.keys(tableData.cells).length > 0 ? tableData.cells : (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_data = _input_layout_template.data) === null || _input_layout_template_data === void 0 ? void 0 : (_input_layout_template_data_table = _input_layout_template_data.table) === null || _input_layout_template_data_table === void 0 ? void 0 : (_input_layout_template_data_table_ = _input_layout_template_data_table[0]) === null || _input_layout_template_data_table_ === void 0 ? void 0 : _input_layout_template_data_table_.cells;
1003
1276
  const rows = columns[0].map((_, rowIndex)=>columns.map((col, colIndex)=>{
1004
1277
  var _cells_font, _cells_font1, _cells_fill;
1005
1278
  const cellValue = col[rowIndex];
@@ -1008,7 +1281,8 @@ export const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMa
1008
1281
  const rawFontColor = cells === null || cells === void 0 ? void 0 : (_cells_font = cells.font) === null || _cells_font === void 0 ? void 0 : _cells_font.color;
1009
1282
  let fontColor;
1010
1283
  if (Array.isArray(rawFontColor)) {
1011
- const entry = rawFontColor[colIndex];
1284
+ var _rawFontColor_colIndex;
1285
+ const entry = (_rawFontColor_colIndex = rawFontColor[colIndex]) !== null && _rawFontColor_colIndex !== void 0 ? _rawFontColor_colIndex : rawFontColor[0];
1012
1286
  const colorValue = Array.isArray(entry) ? entry[rowIndex] : entry;
1013
1287
  fontColor = typeof colorValue === 'string' ? colorValue : undefined;
1014
1288
  } else if (typeof rawFontColor === 'string') {
@@ -1017,7 +1291,8 @@ export const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMa
1017
1291
  const rawFontSize = cells === null || cells === void 0 ? void 0 : (_cells_font1 = cells.font) === null || _cells_font1 === void 0 ? void 0 : _cells_font1.size;
1018
1292
  let fontSize;
1019
1293
  if (Array.isArray(rawFontSize)) {
1020
- const entry = rawFontSize[colIndex];
1294
+ var _rawFontSize_colIndex;
1295
+ const entry = (_rawFontSize_colIndex = rawFontSize[colIndex]) !== null && _rawFontSize_colIndex !== void 0 ? _rawFontSize_colIndex : rawFontSize[0];
1021
1296
  const fontSizeValue = Array.isArray(entry) ? entry[rowIndex] : entry;
1022
1297
  fontSize = typeof fontSizeValue === 'number' ? fontSizeValue : undefined;
1023
1298
  } else if (typeof rawFontSize === 'number') {
@@ -1027,13 +1302,15 @@ export const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMa
1027
1302
  const rawBackgroundColor = cells === null || cells === void 0 ? void 0 : (_cells_fill = cells.fill) === null || _cells_fill === void 0 ? void 0 : _cells_fill.color;
1028
1303
  let backgroundColor;
1029
1304
  if (Array.isArray(rawBackgroundColor)) {
1030
- const entry = rawBackgroundColor[updatedColIndex];
1305
+ var _rawBackgroundColor_updatedColIndex;
1306
+ const entry = (_rawBackgroundColor_updatedColIndex = rawBackgroundColor[updatedColIndex]) !== null && _rawBackgroundColor_updatedColIndex !== void 0 ? _rawBackgroundColor_updatedColIndex : rawBackgroundColor[0];
1031
1307
  const colorValue = Array.isArray(entry) ? entry[rowIndex] : entry;
1032
1308
  backgroundColor = typeof colorValue === 'string' ? colorValue : undefined;
1033
1309
  } else if (typeof rawBackgroundColor === 'string') {
1034
1310
  backgroundColor = rawBackgroundColor;
1035
1311
  }
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;
1312
+ var _cells_align_colIndex;
1313
+ const rawTextAlign = Array.isArray(cells === null || cells === void 0 ? void 0 : cells.align) ? (_cells_align_colIndex = cells.align[colIndex]) !== null && _cells_align_colIndex !== void 0 ? _cells_align_colIndex : cells.align[0] : cells === null || cells === void 0 ? void 0 : cells.align;
1037
1314
  const textAlign = rawTextAlign;
1038
1315
  const style = {
1039
1316
  ...fontColor ? {
@@ -1063,35 +1340,297 @@ export const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMa
1063
1340
  };
1064
1341
  var _tableData_header_values;
1065
1342
  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),
1343
+ 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.header && Object.keys(tableData.header).length > 0 ? 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
1344
  rows,
1068
1345
  width: (_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : _input_layout3.width,
1069
1346
  height: (_input_layout4 = input.layout) === null || _input_layout4 === void 0 ? void 0 : _input_layout4.height,
1070
1347
  styles
1071
1348
  };
1072
1349
  };
1350
+ function getCategoriesAndValues(series) {
1351
+ const orientation = series.orientation || 'h';
1352
+ var _series_labels, _ref;
1353
+ const y = (_ref = (_series_labels = series.labels) !== null && _series_labels !== void 0 ? _series_labels : series.y) !== null && _ref !== void 0 ? _ref : series.stage;
1354
+ var _series_values, _ref1;
1355
+ const x = (_ref1 = (_series_values = series.values) !== null && _series_values !== void 0 ? _series_values : series.x) !== null && _ref1 !== void 0 ? _ref1 : series.value;
1356
+ const xIsString = isStringArray(x);
1357
+ const yIsString = isStringArray(y);
1358
+ const xIsNumber = isNumberArray(x);
1359
+ const yIsNumber = isNumberArray(y);
1360
+ // Helper to ensure array of (string | number)
1361
+ const toArray = (arr)=>{
1362
+ if (Array.isArray(arr)) {
1363
+ return arr;
1364
+ }
1365
+ if (typeof arr === 'string' || typeof arr === 'number') {
1366
+ return [
1367
+ arr
1368
+ ];
1369
+ }
1370
+ return [];
1371
+ };
1372
+ if (orientation === 'h') {
1373
+ if (yIsString && xIsNumber) {
1374
+ return {
1375
+ categories: toArray(y),
1376
+ values: toArray(x)
1377
+ };
1378
+ } else if (xIsString && yIsNumber) {
1379
+ return {
1380
+ categories: toArray(x),
1381
+ values: toArray(y)
1382
+ };
1383
+ } else {
1384
+ return {
1385
+ categories: yIsString ? toArray(y) : toArray(x),
1386
+ values: yIsString ? toArray(x) : toArray(y)
1387
+ };
1388
+ }
1389
+ } else {
1390
+ if (xIsString && yIsNumber) {
1391
+ return {
1392
+ categories: toArray(x),
1393
+ values: toArray(y)
1394
+ };
1395
+ } else if (yIsString && xIsNumber) {
1396
+ return {
1397
+ categories: toArray(y),
1398
+ values: toArray(x)
1399
+ };
1400
+ } else {
1401
+ return {
1402
+ categories: xIsString ? toArray(x) : toArray(y),
1403
+ values: xIsString ? toArray(y) : toArray(x)
1404
+ };
1405
+ }
1406
+ }
1407
+ }
1408
+ export const transformPlotlyJsonToFunnelChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
1409
+ var _input_layout, _input_layout1, _input_data_, _input_layout2;
1410
+ const funnelData = [];
1411
+ // Determine if data is stacked based on multiple series with multiple values per series
1412
+ const isStacked = input.data.length > 1 && input.data.every((series)=>{
1413
+ var _series_values, _ref;
1414
+ const values = (_ref = (_series_values = series.values) !== null && _series_values !== void 0 ? _series_values : series.x) !== null && _ref !== void 0 ? _ref : series.value;
1415
+ var _series_labels, _ref1;
1416
+ const labels = (_ref1 = (_series_labels = series.labels) !== null && _series_labels !== void 0 ? _series_labels : series.y) !== null && _ref1 !== void 0 ? _ref1 : series.stage;
1417
+ return Array.isArray(labels) && Array.isArray(values) && values.length > 1 && labels.length > 1;
1418
+ });
1419
+ if (isStacked) {
1420
+ // Assign a color per series/category and use it for all subValues of that category
1421
+ const seriesColors = {};
1422
+ input.data.forEach((series, seriesIdx)=>{
1423
+ var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _series_marker1;
1424
+ const category = series.name || `Category ${seriesIdx + 1}`;
1425
+ var _series_marker_colors;
1426
+ // Use the same color for this category across all stages
1427
+ const extractedColors = extractColor((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_series_marker_colors = (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.colors) !== null && _series_marker_colors !== void 0 ? _series_marker_colors : (_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color, colorMap, isDarkTheme);
1428
+ // Always use the first color for the series/category
1429
+ const color = resolveColor(extractedColors, 0, category, colorMap, isDarkTheme);
1430
+ seriesColors[category] = color;
1431
+ var _series_labels, _ref;
1432
+ const labels = (_ref = (_series_labels = series.labels) !== null && _series_labels !== void 0 ? _series_labels : series.y) !== null && _ref !== void 0 ? _ref : series.stage;
1433
+ var _series_values, _ref1;
1434
+ const values = (_ref1 = (_series_values = series.values) !== null && _series_values !== void 0 ? _series_values : series.x) !== null && _ref1 !== void 0 ? _ref1 : series.value;
1435
+ if (!isArrayOrTypedArray(labels) || !isArrayOrTypedArray(values)) {
1436
+ return;
1437
+ }
1438
+ if (labels && isArrayOrTypedArray(labels) && labels.length > 0) {
1439
+ labels.forEach((label, i)=>{
1440
+ const stageIndex = funnelData.findIndex((stage)=>stage.stage === label);
1441
+ const valueNum = Number(values[i]);
1442
+ if (isNaN(valueNum)) {
1443
+ return;
1444
+ }
1445
+ if (stageIndex === -1) {
1446
+ funnelData.push({
1447
+ stage: label,
1448
+ subValues: [
1449
+ {
1450
+ category,
1451
+ value: valueNum,
1452
+ color
1453
+ }
1454
+ ]
1455
+ });
1456
+ } else {
1457
+ funnelData[stageIndex].subValues.push({
1458
+ category,
1459
+ value: valueNum,
1460
+ color
1461
+ });
1462
+ }
1463
+ });
1464
+ }
1465
+ });
1466
+ } else {
1467
+ // Non-stacked data handling (multiple series with single-value arrays)
1468
+ input.data.forEach((series, seriesIdx)=>{
1469
+ var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _series_marker1;
1470
+ const { categories, values } = getCategoriesAndValues(series);
1471
+ if (!isArrayOrTypedArray(categories) || !isArrayOrTypedArray(values)) {
1472
+ return;
1473
+ }
1474
+ var _series_marker_colors;
1475
+ const extractedColors = extractColor((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_series_marker_colors = (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.colors) !== null && _series_marker_colors !== void 0 ? _series_marker_colors : (_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color, colorMap, isDarkTheme);
1476
+ categories.forEach((label, i)=>{
1477
+ const color = resolveColor(extractedColors, i, label, colorMap, isDarkTheme);
1478
+ const valueNum = Number(values[i]);
1479
+ if (isNaN(valueNum)) {
1480
+ return;
1481
+ }
1482
+ funnelData.push({
1483
+ stage: label,
1484
+ value: valueNum,
1485
+ color
1486
+ });
1487
+ });
1488
+ });
1489
+ }
1490
+ return {
1491
+ data: funnelData,
1492
+ width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
1493
+ height: (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.height,
1494
+ orientation: ((_input_data_ = input.data[0]) === null || _input_data_ === void 0 ? void 0 : _input_data_.orientation) === 'v' ? 'horizontal' : 'vertical',
1495
+ hideLegend: isMultiPlot || ((_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.showlegend) === false
1496
+ };
1497
+ };
1073
1498
  export const projectPolarToCartesian = (input)=>{
1499
+ var _input_layout, _input_layout1;
1074
1500
  const projection = {
1075
1501
  ...input
1076
1502
  };
1503
+ // Find the global min and max radius across all series
1504
+ let minRadius = 0;
1505
+ let maxRadius = 0;
1077
1506
  for(let sindex = 0; sindex < input.data.length; sindex++){
1078
- var _series_r;
1507
+ const rVals = input.data[sindex].r;
1508
+ if (rVals && isArrayOrTypedArray(rVals)) {
1509
+ for(let ptindex = 0; ptindex < rVals.length; ptindex++){
1510
+ if (!isInvalidValue(rVals[ptindex])) {
1511
+ minRadius = Math.min(minRadius, rVals[ptindex]);
1512
+ maxRadius = Math.max(maxRadius, rVals[ptindex]);
1513
+ }
1514
+ }
1515
+ }
1516
+ }
1517
+ // If there are negative radii, compute the shift
1518
+ const radiusShift = minRadius < 0 ? -minRadius : 0;
1519
+ // Collect all unique theta values from all scatterpolar series for equal spacing
1520
+ const allThetaValues = new Set();
1521
+ for(let sindex = 0; sindex < input.data.length; sindex++){
1522
+ const series = input.data[sindex];
1523
+ if (series.theta && isArrayOrTypedArray(series.theta)) {
1524
+ series.theta.forEach((theta)=>allThetaValues.add(String(theta)));
1525
+ }
1526
+ }
1527
+ // Project all points and create a perfect square domain
1528
+ const allX = [];
1529
+ const allY = [];
1530
+ let originX = null;
1531
+ for(let sindex = 0; sindex < input.data.length; sindex++){
1532
+ var _input_layout_polar_angularaxis, _input_layout_polar, _input_layout2, _input_layout_polar_angularaxis1, _input_layout_polar1, _input_layout3;
1079
1533
  const series = input.data[sindex];
1534
+ // If scatterpolar, set __axisLabel to all unique theta values for equal spacing
1535
+ if (isArrayOrTypedArray(series.theta)) {
1536
+ series.__axisLabel = Array.from(allThetaValues);
1537
+ }
1080
1538
  series.x = [];
1081
1539
  series.y = [];
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])) {
1540
+ const thetas = series.theta;
1541
+ const rVals = series.r;
1542
+ // Skip if rVals or thetas are not arrays
1543
+ if (!isArrayOrTypedArray(rVals) || !isArrayOrTypedArray(thetas)) {
1544
+ projection.data[sindex] = series;
1545
+ continue;
1546
+ }
1547
+ // retrieve polar axis settings
1548
+ const dirMultiplier = ((_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : (_input_layout_polar = _input_layout2.polar) === null || _input_layout_polar === void 0 ? void 0 : (_input_layout_polar_angularaxis = _input_layout_polar.angularaxis) === null || _input_layout_polar_angularaxis === void 0 ? void 0 : _input_layout_polar_angularaxis.direction) === 'clockwise' ? -1 : 1;
1549
+ var _input_layout_polar_angularaxis_rotation;
1550
+ const startAngleInRad = ((_input_layout_polar_angularaxis_rotation = (_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : (_input_layout_polar1 = _input_layout3.polar) === null || _input_layout_polar1 === void 0 ? void 0 : (_input_layout_polar_angularaxis1 = _input_layout_polar1.angularaxis) === null || _input_layout_polar_angularaxis1 === void 0 ? void 0 : _input_layout_polar_angularaxis1.rotation) !== null && _input_layout_polar_angularaxis_rotation !== void 0 ? _input_layout_polar_angularaxis_rotation : 0) * Math.PI / 180;
1551
+ // Compute tick positions if categorical
1552
+ let uniqueTheta = [];
1553
+ let categorical = false;
1554
+ if (!isNumberArray(thetas)) {
1555
+ uniqueTheta = Array.from(new Set(thetas));
1556
+ categorical = true;
1557
+ }
1558
+ for(let ptindex = 0; ptindex < rVals.length; ptindex++){
1559
+ if (isInvalidValue(thetas === null || thetas === void 0 ? void 0 : thetas[ptindex]) || isInvalidValue(rVals === null || rVals === void 0 ? void 0 : rVals[ptindex])) {
1086
1560
  continue;
1087
1561
  }
1088
- const thetaRad = series.theta[ptindex] * Math.PI / 180;
1089
- const radius = series.r[ptindex];
1090
- series.x.push(radius * Math.cos(thetaRad));
1091
- series.y.push(radius * Math.sin(thetaRad));
1562
+ // Map theta to angle in radians
1563
+ let thetaRad;
1564
+ if (categorical) {
1565
+ const idx = uniqueTheta.indexOf(thetas[ptindex]);
1566
+ const step = 2 * Math.PI / uniqueTheta.length;
1567
+ thetaRad = startAngleInRad + dirMultiplier * idx * step;
1568
+ } else {
1569
+ thetaRad = startAngleInRad + dirMultiplier * (thetas[ptindex] * Math.PI / 180);
1570
+ }
1571
+ // Shift only the polar origin (not the cartesian)
1572
+ const rawRadius = rVals[ptindex];
1573
+ const polarRadius = rawRadius + radiusShift; // Only for projection
1574
+ // Calculate cartesian coordinates (with shifted polar origin)
1575
+ const x = polarRadius * Math.cos(thetaRad);
1576
+ const y = polarRadius * Math.sin(thetaRad);
1577
+ // Calculate the cartesian coordinates of the original polar origin (0,0)
1578
+ // This is the point that should be mapped to (0,0) in cartesian coordinates
1579
+ if (sindex === 0 && ptindex === 0) {
1580
+ // For polar origin (r=0, θ=0), cartesian coordinates are (0,0)
1581
+ // But since we shifted the radius by radiusShift, the cartesian origin is at (radiusShift, 0)
1582
+ originX = radiusShift;
1583
+ }
1584
+ series.x.push(x);
1585
+ series.y.push(y);
1586
+ allX.push(x);
1587
+ allY.push(y);
1588
+ }
1589
+ // Map text to each data point for downstream chart rendering
1590
+ if (series.x && series.y) {
1591
+ series.data = series.x.map((xVal, idx)=>({
1592
+ x: xVal,
1593
+ y: series.y[idx],
1594
+ ...series.text ? {
1595
+ text: series.text[idx]
1596
+ } : {}
1597
+ }));
1092
1598
  }
1093
1599
  projection.data[sindex] = series;
1094
1600
  }
1601
+ // 7. Recenter all cartesian coordinates
1602
+ if (originX !== null) {
1603
+ for(let sindex = 0; sindex < projection.data.length; sindex++){
1604
+ const series = projection.data[sindex];
1605
+ if (series.x && series.y) {
1606
+ series.x = series.x.map((v)=>v - originX);
1607
+ }
1608
+ }
1609
+ // Also recenter allX for normalization
1610
+ for(let i = 0; i < allX.length; i++){
1611
+ allX[i] = allX[i] - originX;
1612
+ }
1613
+ }
1614
+ // 8. Find the maximum absolute value among all x and y
1615
+ let maxAbs = Math.max(...allX.map(Math.abs), ...allY.map(Math.abs));
1616
+ maxAbs = maxAbs === 0 ? 1 : maxAbs;
1617
+ // 9. Rescale all points so that the largest |x| or |y| is 0.5
1618
+ for(let sindex = 0; sindex < projection.data.length; sindex++){
1619
+ const series = projection.data[sindex];
1620
+ if (series.x && series.y) {
1621
+ series.x = series.x.map((v)=>v / (2 * maxAbs));
1622
+ series.y = series.y.map((v)=>v / (2 * maxAbs));
1623
+ }
1624
+ }
1625
+ // 10. Customize layout for perfect square with absolute positioning
1626
+ const size = ((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width) || ((_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.height) || 500;
1627
+ projection.layout = {
1628
+ ...projection.layout,
1629
+ width: size,
1630
+ height: size
1631
+ };
1632
+ // Attach originX as custom properties
1633
+ projection.layout.__polarOriginX = originX !== null && originX !== void 0 ? originX : undefined;
1095
1634
  return projection;
1096
1635
  };
1097
1636
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -1202,7 +1741,7 @@ const createBins = (data, binStart, binEnd, binSize)=>{
1202
1741
  ]);
1203
1742
  if (typeof binSize === 'number' && binSize > 0) {
1204
1743
  const thresholds = [];
1205
- const precision = Math.max(getPrecision(minVal), getPrecision(binSize));
1744
+ const precision = Math.max(calculatePrecision(minVal), calculatePrecision(binSize));
1206
1745
  let th = precisionRound(minVal, precision);
1207
1746
  while(th < precisionRound(maxVal + binSize, precision)){
1208
1747
  thresholds.push(th);
@@ -1252,15 +1791,6 @@ const calculateHistNorm = (histnorm, value, total, dx, dy = 1)=>{
1252
1791
  return value;
1253
1792
  }
1254
1793
  };
1255
- const getPrecision = (value)=>{
1256
- var _value_toString_split_;
1257
- var _value_toString_split__length;
1258
- return (_value_toString_split__length = (_value_toString_split_ = value.toString().split('.')[1]) === null || _value_toString_split_ === void 0 ? void 0 : _value_toString_split_.length) !== null && _value_toString_split__length !== void 0 ? _value_toString_split__length : 0;
1259
- };
1260
- const precisionRound = (value, precision)=>{
1261
- const factor = Math.pow(10, precision);
1262
- return Math.round(value * factor) / factor;
1263
- };
1264
1794
  const getLegendShape = (series)=>{
1265
1795
  var _series_line, _series_mode;
1266
1796
  const dashType = ((_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.dash) || 'solid';
@@ -1271,25 +1801,44 @@ const getLegendShape = (series)=>{
1271
1801
  }
1272
1802
  return 'default';
1273
1803
  };
1274
- export const getAllupLegendsProps = (input, colorMap, colorwayType, isDarkTheme)=>{
1804
+ export const getAllupLegendsProps = (input, colorMap, colorwayType, traceInfo, isDarkTheme)=>{
1275
1805
  const allupLegends = [];
1276
1806
  // reduce on showlegend boolean propperty. reduce should return true if at least one series has showlegend true
1277
1807
  const toShowLegend = input.data.reduce((acc, series)=>{
1278
- return acc || series.showlegend === true;
1808
+ return acc || series.showlegend === true || series.showlegend === undefined;
1279
1809
  }, false);
1280
1810
  if (toShowLegend) {
1281
1811
  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
1812
+ if (traceInfo[index].type === 'donut') {
1813
+ var _input_layout, _input_layout_template_layout, _input_layout_template, _input_layout1, _input_layout2, _pieSeries_marker, _pieSeries_labels;
1814
+ const pieSeries = series;
1815
+ var _input_layout_piecolorway, _input_layout_piecolorway1;
1816
+ const colors = extractColor((_input_layout_piecolorway = (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.piecolorway) !== null && _input_layout_piecolorway !== void 0 ? _input_layout_piecolorway : (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_template = _input_layout1.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_input_layout_piecolorway1 = (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.piecolorway) !== null && _input_layout_piecolorway1 !== void 0 ? _input_layout_piecolorway1 : pieSeries === null || pieSeries === void 0 ? void 0 : (_pieSeries_marker = pieSeries.marker) === null || _pieSeries_marker === void 0 ? void 0 : _pieSeries_marker.colors, colorMap, isDarkTheme);
1817
+ (_pieSeries_labels = pieSeries.labels) === null || _pieSeries_labels === void 0 ? void 0 : _pieSeries_labels.forEach((label, labelIndex)=>{
1818
+ const legend = `${label}`;
1819
+ // resolve color for each legend from the extracted colors
1820
+ const color = resolveColor(colors, labelIndex, legend, colorMap, isDarkTheme);
1821
+ if (legend !== '' && allupLegends.some((group)=>group.title === legend) === false) {
1822
+ allupLegends.push({
1823
+ title: legend,
1824
+ color
1825
+ });
1826
+ }
1292
1827
  });
1828
+ } else if (isNonPlotType(traceInfo[index].type) === false) {
1829
+ var _plotSeries_line, _plotSeries_marker, _input_layout_template_layout1, _input_layout_template1, _input_layout3;
1830
+ const plotSeries = series;
1831
+ const name = plotSeries.legendgroup;
1832
+ const color = ((_plotSeries_line = plotSeries.line) === null || _plotSeries_line === void 0 ? void 0 : _plotSeries_line.color) || ((_plotSeries_marker = plotSeries.marker) === null || _plotSeries_marker === void 0 ? void 0 : _plotSeries_marker.color);
1833
+ const legendShape = getLegendShape(plotSeries);
1834
+ const resolvedColor = extractColor((_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : (_input_layout_template1 = _input_layout3.template) === null || _input_layout_template1 === void 0 ? void 0 : (_input_layout_template_layout1 = _input_layout_template1.layout) === null || _input_layout_template_layout1 === void 0 ? void 0 : _input_layout_template_layout1.colorway, colorwayType, color, colorMap, isDarkTheme);
1835
+ if (name !== undefined && name !== '' && allupLegends.some((group)=>group.title === name) === false) {
1836
+ allupLegends.push({
1837
+ title: name,
1838
+ color: resolvedColor,
1839
+ shape: legendShape
1840
+ });
1841
+ }
1293
1842
  }
1294
1843
  });
1295
1844
  }
@@ -1355,28 +1904,21 @@ const getIndexFromKey = (key, pattern)=>{
1355
1904
  const normalizedKey = key.replace(pattern, '') === '' ? '1' : key.replace(pattern, '');
1356
1905
  return parseInt(normalizedKey, 10) - 1;
1357
1906
  };
1358
- export const getGridProperties = (layout, isMultiPlot)=>{
1359
- var _layout_annotations;
1360
- const gridX = [];
1361
- const gridY = [];
1907
+ export const isNonPlotType = (chartType)=>{
1908
+ return [
1909
+ 'donut',
1910
+ 'sankey',
1911
+ 'pie'
1912
+ ].includes(chartType);
1913
+ };
1914
+ export const getGridProperties = (schema, isMultiPlot, validTracesInfo)=>{
1915
+ const domainX = [];
1916
+ const domainY = [];
1917
+ let cartesianDomains = 0;
1362
1918
  const annotations = {};
1363
1919
  let templateRows = '1fr';
1364
1920
  let templateColumns = '1fr';
1365
1921
  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
1922
  if (!isMultiPlot) {
1381
1923
  return {
1382
1924
  templateRows,
@@ -1384,144 +1926,144 @@ export const getGridProperties = (layout, isMultiPlot)=>{
1384
1926
  layout: gridLayout
1385
1927
  };
1386
1928
  }
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
- };
1929
+ const layout = schema === null || schema === void 0 ? void 0 : schema.layout;
1930
+ if (layout !== undefined && layout !== null && Object.keys(layout).length > 0) {
1931
+ Object.keys(layout !== null && layout !== void 0 ? layout : {}).forEach((key)=>{
1932
+ if (key.startsWith('xaxis')) {
1933
+ var _layout_key;
1934
+ const index = getIndexFromKey(key, 'xaxis');
1935
+ var _layout_key_anchor;
1936
+ 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';
1937
+ const anchorIndex = getIndexFromKey(anchor, 'y');
1938
+ if (index !== anchorIndex) {
1939
+ throw new Error(`Invalid layout: xaxis ${index + 1} anchor should be y${anchorIndex + 1}`);
1940
+ }
1941
+ const xAxisLayout = layout[key];
1942
+ const domainXInfo = {
1943
+ start: (xAxisLayout === null || xAxisLayout === void 0 ? void 0 : xAxisLayout.domain) ? xAxisLayout.domain[0] : 0,
1944
+ end: (xAxisLayout === null || xAxisLayout === void 0 ? void 0 : xAxisLayout.domain) ? xAxisLayout.domain[1] : 1
1945
+ };
1946
+ domainX.push(domainXInfo);
1947
+ } else if (key.startsWith('yaxis')) {
1948
+ var _layout_key1;
1949
+ const index = getIndexFromKey(key, 'yaxis');
1950
+ var _layout_key_anchor1;
1951
+ const anchor = (_layout_key_anchor1 = (_layout_key1 = layout[key]) === null || _layout_key1 === void 0 ? void 0 : _layout_key1.anchor) !== null && _layout_key_anchor1 !== void 0 ? _layout_key_anchor1 : 'x';
1952
+ const anchorIndex = getIndexFromKey(anchor, 'x');
1953
+ if (index !== anchorIndex) {
1954
+ var _layout_yaxis2;
1955
+ if (index === 1 && anchorIndex === 0 || ((_layout_yaxis2 = layout.yaxis2) === null || _layout_yaxis2 === void 0 ? void 0 : _layout_yaxis2.side) === 'right') {
1956
+ // Special case for secondary y axis where yaxis2 can anchor to x1
1957
+ return {
1958
+ templateRows,
1959
+ templateColumns
1960
+ };
1961
+ }
1962
+ throw new Error(`Invalid layout: yaxis ${index + 1} anchor should be x${anchorIndex + 1}`);
1413
1963
  }
1414
- throw new Error(`Invalid layout: yaxis ${index + 1} anchor should be x${anchorIndex + 1}`);
1964
+ const yAxisLayout = layout[key];
1965
+ const domainYInfo = {
1966
+ start: (yAxisLayout === null || yAxisLayout === void 0 ? void 0 : yAxisLayout.domain) ? yAxisLayout.domain[0] : 0,
1967
+ end: (yAxisLayout === null || yAxisLayout === void 0 ? void 0 : yAxisLayout.domain) ? yAxisLayout.domain[1] : 1
1968
+ };
1969
+ domainY.push(domainYInfo);
1415
1970
  }
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 : [];
1971
+ });
1972
+ }
1973
+ cartesianDomains = domainX.length; // Assuming that the number of x and y axes is the same
1974
+ validTracesInfo.forEach((trace, index)=>{
1975
+ if (isNonPlotType(trace.type)) {
1976
+ var _schema_data, _series_domain, _series_domain1, _series_domain2, _series_domain3;
1977
+ const series = schema === null || schema === void 0 ? void 0 : (_schema_data = schema.data) === null || _schema_data === void 0 ? void 0 : _schema_data[index];
1978
+ const domainXInfo = {
1979
+ start: ((_series_domain = series.domain) === null || _series_domain === void 0 ? void 0 : _series_domain.x) ? series.domain.x[0] : 0,
1980
+ end: ((_series_domain1 = series.domain) === null || _series_domain1 === void 0 ? void 0 : _series_domain1.x) ? series.domain.x[1] : 1
1981
+ };
1982
+ const domainYInfo = {
1983
+ start: ((_series_domain2 = series.domain) === null || _series_domain2 === void 0 ? void 0 : _series_domain2.y) ? series.domain.y[0] : 0,
1984
+ end: ((_series_domain3 = series.domain) === null || _series_domain3 === void 0 ? void 0 : _series_domain3.y) ? series.domain.y[1] : 1
1985
+ };
1986
+ domainX.push(domainXInfo);
1987
+ domainY.push(domainYInfo);
1418
1988
  }
1419
1989
  });
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;
1990
+ if (layout !== undefined && layout !== null && Object.keys(layout).length > 0) {
1991
+ var _layout_annotations;
1992
+ (_layout_annotations = layout.annotations) === null || _layout_annotations === void 0 ? void 0 : _layout_annotations.forEach((annotation)=>{
1993
+ const xMatches = domainX.flatMap((interval, idx)=>(annotation === null || annotation === void 0 ? void 0 : annotation.x) >= interval.start && (annotation === null || annotation === void 0 ? void 0 : annotation.x) <= interval.end ? [
1994
+ idx
1995
+ ] : []);
1996
+ const yMatch = domainY.findIndex((interval, yIndex)=>xMatches.includes(yIndex) && (annotation === null || annotation === void 0 ? void 0 : annotation.y) >= interval.start && (annotation === null || annotation === void 0 ? void 0 : annotation.y) <= interval.end);
1997
+ if (yMatch !== -1) {
1998
+ if (annotations[yMatch] === undefined) {
1999
+ annotations[yMatch] = {};
2000
+ }
2001
+ if ((annotation === null || annotation === void 0 ? void 0 : annotation.textangle) === 90) {
2002
+ annotations[yMatch].yAnnotation = annotation.text;
2003
+ } else {
2004
+ annotations[yMatch].xAnnotation = annotation.text;
2005
+ }
1433
2006
  }
1434
- }
1435
- });
1436
- if (gridX.length > 0) {
2007
+ });
2008
+ }
2009
+ if (domainX.length > 0) {
1437
2010
  const uniqueXIntervals = new Map();
1438
- gridX.forEach((interval)=>{
1439
- const key = `${interval[0]}-${interval[1]}`;
2011
+ domainX.forEach((interval)=>{
2012
+ const key = `${interval.start}-${interval.end}`;
1440
2013
  if (!uniqueXIntervals.has(key)) {
1441
2014
  uniqueXIntervals.set(key, interval);
1442
2015
  }
1443
2016
  });
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}`;
2017
+ const sortedXStart = Array.from(uniqueXIntervals.values()).map((interval)=>interval.start).sort();
2018
+ templateColumns = `repeat(${sortedXStart.length}, 1fr)`;
2019
+ domainX.forEach((interval, index)=>{
2020
+ const cellName = index >= cartesianDomains ? `${NON_PLOT_KEY_PREFIX}${index - cartesianDomains + 1}` : `x${index === 0 ? '' : index + 1}`;
2021
+ const columnIndex = sortedXStart.findIndex((start)=>start === interval.start);
2022
+ const columnNumber = columnIndex + 1; // Column numbers are 1-based
1453
2023
  const annotationProps = annotations[index];
1454
2024
  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
2025
  const row = {
1460
2026
  row: -1,
1461
2027
  column: columnNumber,
1462
- xAnnotation
2028
+ xAnnotation,
2029
+ xDomain: interval,
2030
+ yDomain: {
2031
+ start: 0,
2032
+ end: 1
2033
+ }
1463
2034
  };
1464
2035
  gridLayout[cellName] = row;
1465
- columnNumber += 1;
1466
2036
  });
1467
2037
  }
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) {
2038
+ if (domainY.length > 0) {
1480
2039
  const uniqueYIntervals = new Map();
1481
- gridY.forEach((interval)=>{
1482
- const key = `${interval[0]}-${interval[1]}`;
2040
+ domainY.forEach((interval)=>{
2041
+ const key = `${interval.start}-${interval.end}`;
1483
2042
  if (!uniqueYIntervals.has(key)) {
1484
2043
  uniqueYIntervals.set(key, interval);
1485
2044
  }
1486
2045
  });
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}`;
2046
+ const sortedYStart = Array.from(uniqueYIntervals.values()).map((interval)=>interval.start).sort();
2047
+ const numberOfRows = sortedYStart.length;
2048
+ templateRows = `repeat(${numberOfRows}, 1fr)`;
2049
+ domainY.forEach((interval, index)=>{
2050
+ const cellName = index >= cartesianDomains ? `${NON_PLOT_KEY_PREFIX}${index - cartesianDomains + 1}` : `x${index === 0 ? '' : index + 1}`;
2051
+ const rowIndex = sortedYStart.findIndex((start)=>start === interval.start);
2052
+ const rowNumber = numberOfRows - rowIndex; // Rows are 1-based and we need to reverse the order for CSS grid
1494
2053
  const annotationProps = annotations[index];
1495
2054
  const yAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.yAnnotation;
1496
2055
  const cell = gridLayout[cellName];
1497
2056
  if (cell !== undefined) {
1498
- cell.row = columnFill[cell.column].row;
2057
+ cell.row = rowNumber;
1499
2058
  cell.yAnnotation = yAnnotation;
2059
+ cell.yDomain = interval;
1500
2060
  }
1501
- columnFill[cell.column].fillDomain = interval[1];
1502
- columnFill[cell.column].row += 1;
1503
2061
  });
1504
2062
  }
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
2063
  return {
1522
2064
  templateRows,
1523
2065
  templateColumns,
1524
- layout: reversedGridLayout
2066
+ layout: gridLayout
1525
2067
  };
1526
2068
  };
1527
2069
  /**
@@ -1563,3 +2105,228 @@ export const getGridProperties = (layout, isMultiPlot)=>{
1563
2105
  });
1564
2106
  return result;
1565
2107
  };
2108
+ const getBarProps = (data, layout, isHorizontal)=>{
2109
+ let padding;
2110
+ if (typeof (layout === null || layout === void 0 ? void 0 : layout.bargap) === 'number') {
2111
+ if (layout.bargap >= 0 && layout.bargap <= 1) {
2112
+ padding = layout.bargap;
2113
+ } else {
2114
+ // Plotly uses a default bargap of 0.2, as noted here: https://github.com/plotly/plotly.js/blob/1d5a249e43dd31ae50acf02117a19e5ac97387e9/src/traces/bar/layout_defaults.js#L58.
2115
+ // However, we don't use this value as our default padding because it causes the bars to
2116
+ // appear disproportionately wide in large containers.
2117
+ padding = 0.2;
2118
+ }
2119
+ }
2120
+ const plotlyBarWidths = data.map((series)=>{
2121
+ if (series.type === 'bar' && (isArrayOrTypedArray(series.width) || typeof series.width === 'number')) {
2122
+ return series.width;
2123
+ }
2124
+ return [];
2125
+ }).flat();
2126
+ const maxPlotlyBarWidth = d3Max(plotlyBarWidths);
2127
+ if (typeof maxPlotlyBarWidth === 'number') {
2128
+ padding = 1 - maxPlotlyBarWidth;
2129
+ padding = Math.max(0, Math.min(padding, 1));
2130
+ }
2131
+ if (typeof padding === 'undefined') {
2132
+ return {};
2133
+ }
2134
+ if (isHorizontal) {
2135
+ return {
2136
+ maxBarHeight: 1000,
2137
+ yAxisPadding: padding
2138
+ };
2139
+ }
2140
+ return {
2141
+ barWidth: 'auto',
2142
+ maxBarWidth: 1000,
2143
+ xAxisInnerPadding: padding,
2144
+ xAxisOuterPadding: padding / 2
2145
+ };
2146
+ };
2147
+ const getAxisScaleTypeProps = (data, layout)=>{
2148
+ var _axisObjects_x, _axisObjects_y, _axisObjects_y2;
2149
+ const result = {};
2150
+ const axisObjects = getAxisObjects(data, layout);
2151
+ if (((_axisObjects_x = axisObjects.x) === null || _axisObjects_x === void 0 ? void 0 : _axisObjects_x.type) === 'log') {
2152
+ result.xScaleType = 'log';
2153
+ }
2154
+ if (((_axisObjects_y = axisObjects.y) === null || _axisObjects_y === void 0 ? void 0 : _axisObjects_y.type) === 'log') {
2155
+ result.yScaleType = 'log';
2156
+ }
2157
+ if (((_axisObjects_y2 = axisObjects.y2) === null || _axisObjects_y2 === void 0 ? void 0 : _axisObjects_y2.type) === 'log') {
2158
+ result.secondaryYScaleType = 'log';
2159
+ }
2160
+ return result;
2161
+ };
2162
+ /**
2163
+ * @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/tick_value_defaults.js#L8}
2164
+ */ const getAxisTickProps = (data, layout)=>{
2165
+ const props = {};
2166
+ const axisObjects = getAxisObjects(data, layout);
2167
+ Object.keys(axisObjects).forEach((axId)=>{
2168
+ const ax = axisObjects[axId];
2169
+ if (!ax) {
2170
+ return;
2171
+ }
2172
+ const axType = getAxisType(data, axId[0], ax);
2173
+ if ((!ax.tickmode || ax.tickmode === 'array') && isArrayOrTypedArray(ax.tickvals)) {
2174
+ const tickValues = axType === 'date' ? ax.tickvals.map((v)=>new Date(v)) : ax.tickvals;
2175
+ if (axId === 'x') {
2176
+ props.tickValues = tickValues;
2177
+ } else if (axId === 'y') {
2178
+ props.yAxisTickValues = tickValues;
2179
+ }
2180
+ return;
2181
+ }
2182
+ if ((!ax.tickmode || ax.tickmode === 'linear') && ax.dtick) {
2183
+ const dtick = plotlyDtick(ax.dtick, axType);
2184
+ const tick0 = plotlyTick0(ax.tick0, axType, dtick);
2185
+ if (axId === 'x') {
2186
+ props.xAxis = {
2187
+ tickStep: dtick,
2188
+ tick0: tick0
2189
+ };
2190
+ } else if (axId === 'y') {
2191
+ props.yAxis = {
2192
+ tickStep: dtick,
2193
+ tick0: tick0
2194
+ };
2195
+ }
2196
+ return;
2197
+ }
2198
+ if ((!ax.tickmode || ax.tickmode === 'auto') && typeof ax.nticks === 'number' && ax.nticks >= 0) {
2199
+ if (axId === 'x') {
2200
+ props.xAxisTickCount = ax.nticks;
2201
+ } else if (axId === 'y') {
2202
+ props.yAxisTickCount = ax.nticks;
2203
+ }
2204
+ }
2205
+ });
2206
+ return props;
2207
+ };
2208
+ /**
2209
+ * @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/clean_ticks.js#L16}
2210
+ */ const plotlyDtick = (dtick, axType)=>{
2211
+ const isLogAx = axType === 'log';
2212
+ const isDateAx = axType === 'date';
2213
+ const isCatAx = axType === 'category';
2214
+ const dtickDflt = isDateAx ? 86400000 : 1;
2215
+ if (!dtick) {
2216
+ return dtickDflt;
2217
+ }
2218
+ if (isNumber(dtick)) {
2219
+ dtick = Number(dtick);
2220
+ if (dtick <= 0) {
2221
+ return dtickDflt;
2222
+ }
2223
+ if (isCatAx) {
2224
+ // category dtick must be positive integers
2225
+ return Math.max(1, Math.round(dtick));
2226
+ }
2227
+ if (isDateAx) {
2228
+ // date dtick must be at least 0.1ms (our current precision)
2229
+ return Math.max(0.1, dtick);
2230
+ }
2231
+ return dtick;
2232
+ }
2233
+ if (typeof dtick !== 'string' || !(isDateAx || isLogAx)) {
2234
+ return dtickDflt;
2235
+ }
2236
+ const prefix = dtick.charAt(0);
2237
+ const dtickNum = isNumber(dtick.slice(1)) ? Number(dtick.slice(1)) : 0;
2238
+ if (dtickNum <= 0 || !// "M<n>" gives ticks every (integer) n months
2239
+ (isDateAx && prefix === 'M' && dtickNum === Math.round(dtickNum) || // "L<f>" gives ticks linearly spaced in data (not in position) every (float) f
2240
+ isLogAx && prefix === 'L' || // "D1" gives powers of 10 with all small digits between, "D2" gives only 2 and 5
2241
+ isLogAx && prefix === 'D' && (dtickNum === 1 || dtickNum === 2))) {
2242
+ return dtickDflt;
2243
+ }
2244
+ return dtick;
2245
+ };
2246
+ /**
2247
+ * @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/clean_ticks.js#L70}
2248
+ */ const plotlyTick0 = (tick0, axType, dtick)=>{
2249
+ if (axType === 'date') {
2250
+ return isDate(tick0) ? new Date(tick0) : new Date(DEFAULT_DATE_STRING);
2251
+ }
2252
+ if (dtick === 'D1' || dtick === 'D2') {
2253
+ // D1 and D2 modes ignore tick0 entirely
2254
+ return undefined;
2255
+ }
2256
+ // Aside from date axes, tick0 must be numeric
2257
+ return isNumber(tick0) ? Number(tick0) : 0;
2258
+ };
2259
+ const getAxisObjects = (data, layout)=>{
2260
+ // Traces are grouped by their xaxis property, and for each group/subplot, the adapter functions
2261
+ // are called with the corresponding filtered data. As a result, all traces passed to an adapter
2262
+ // function share the same xaxis.
2263
+ let xAxisId;
2264
+ const yAxisIds = new Set();
2265
+ data.forEach((series)=>{
2266
+ const axisIds = getAxisIds(series);
2267
+ xAxisId = axisIds.x;
2268
+ yAxisIds.add(axisIds.y);
2269
+ });
2270
+ const axisObjects = {};
2271
+ if (typeof xAxisId === 'number') {
2272
+ axisObjects.x = layout === null || layout === void 0 ? void 0 : layout[getAxisKey('x', xAxisId)];
2273
+ }
2274
+ const sortedYAxisIds = Array.from(yAxisIds).sort();
2275
+ if (sortedYAxisIds.length > 0) {
2276
+ axisObjects.y = layout === null || layout === void 0 ? void 0 : layout[getAxisKey('y', sortedYAxisIds[0])];
2277
+ }
2278
+ if (sortedYAxisIds.length > 1) {
2279
+ axisObjects.y2 = layout === null || layout === void 0 ? void 0 : layout[getAxisKey('y', sortedYAxisIds[1])];
2280
+ }
2281
+ return axisObjects;
2282
+ };
2283
+ const getAxisType = (data, axLetter, ax)=>{
2284
+ const values = [];
2285
+ data.forEach((series)=>{
2286
+ var _series_axLetter;
2287
+ (_series_axLetter = series[axLetter]) === null || _series_axLetter === void 0 ? void 0 : _series_axLetter.forEach((val)=>{
2288
+ if (!isInvalidValue(val)) {
2289
+ values.push(val);
2290
+ }
2291
+ });
2292
+ });
2293
+ // Note: When ax.type is explicitly specified, Plotly casts the values to match that type.
2294
+ // Therefore, simply checking the type of the values may not be sufficient. At the moment,
2295
+ // we don’t always perform this casting ourselves and instead use the values as provided.
2296
+ if (isNumberArray(values)) {
2297
+ if ((ax === null || ax === void 0 ? void 0 : ax.type) === 'log') {
2298
+ return 'log';
2299
+ }
2300
+ return 'linear';
2301
+ }
2302
+ if (isDateArray(values)) {
2303
+ return 'date';
2304
+ }
2305
+ if (isStringArray(values)) {
2306
+ return 'category';
2307
+ }
2308
+ };
2309
+ /**
2310
+ * This is experimental. Use it only with valid datetime strings to verify if they conform to the ISO 8601 format.
2311
+ */ const isoDateRegex = /^\d{4}(-\d{2}(-\d{2})?)?(T\d{2}:\d{2}(:\d{2}(\.\d{1,9})?)?(Z)?)?$/;
2312
+ /**
2313
+ * We want to display localized date and time in the charts, so the useUTC prop is set to false.
2314
+ * But this can sometimes cause the formatters to display the datetime incorrectly.
2315
+ * To work around this issue, we use this function to adjust datetime strings so that they are always interpreted
2316
+ * as local time, allowing the formatters to produce the correct output.
2317
+ *
2318
+ * FIXME: The formatters should always produce a clear and accurate localized output, regardless of the
2319
+ * format used to create the date object.
2320
+ */ const parseLocalDate = (value)=>{
2321
+ if (typeof value === 'string') {
2322
+ const match = value.match(isoDateRegex);
2323
+ if (match) {
2324
+ if (!match[3]) {
2325
+ value += 'T00:00';
2326
+ } else if (match[6]) {
2327
+ value = value.replace('Z', '');
2328
+ }
2329
+ }
2330
+ }
2331
+ return new Date(value);
2332
+ };