@fluentui/react-charts 0.0.0-nightly-20250826-2140.1 → 0.0.0-nightly-20250828-0408.1

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 (158) hide show
  1. package/CHANGELOG.md +48 -15
  2. package/dist/index.d.ts +15 -1
  3. package/lib/components/AreaChart/AreaChart.js +4 -1
  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 +87 -6
  10. package/lib/components/ChartTable/ChartTable.js.map +1 -1
  11. package/lib/components/CommonComponents/CartesianChart.js +24 -24
  12. package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
  13. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +17 -14
  14. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  15. package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +6 -33
  16. package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
  17. package/lib/components/DeclarativeChart/DeclarativeChart.js +42 -16
  18. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  19. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +20 -1
  20. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
  21. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +502 -259
  22. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  23. package/lib/components/DonutChart/DonutChart.js +6 -1
  24. package/lib/components/DonutChart/DonutChart.js.map +1 -1
  25. package/lib/components/DonutChart/DonutChart.types.js.map +1 -1
  26. package/lib/components/DonutChart/useDonutChartStyles.styles.js +21 -4
  27. package/lib/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
  28. package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js +8 -4
  29. package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
  30. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +23 -4
  31. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  32. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +4 -17
  33. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  34. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +4 -21
  35. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
  36. package/lib/components/HeatMapChart/HeatMapChart.js +175 -114
  37. package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
  38. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +26 -6
  39. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  40. package/lib/components/LineChart/LineChart.js +128 -82
  41. package/lib/components/LineChart/LineChart.js.map +1 -1
  42. package/lib/components/LineChart/LineChart.types.js.map +1 -1
  43. package/lib/components/LineChart/useLineChartStyles.styles.js +23 -10
  44. package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  45. package/lib/components/LineChart/useLineChartStyles.styles.raw.js +4 -21
  46. package/lib/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
  47. package/lib/components/SankeyChart/useSankeyChartStyles.styles.js +12 -25
  48. package/lib/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
  49. package/lib/components/SankeyChart/useSankeyChartStyles.styles.raw.js +2 -12
  50. package/lib/components/SankeyChart/useSankeyChartStyles.styles.raw.js.map +1 -1
  51. package/lib/components/ScatterChart/ScatterChart.js +86 -59
  52. package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
  53. package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -1
  54. package/lib/components/ScatterChart/useScatterChartStyles.styles.js +27 -7
  55. package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  56. package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js +8 -14
  57. package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
  58. package/lib/components/VerticalBarChart/VerticalBarChart.js +27 -4
  59. package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  60. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +8 -6
  61. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  62. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +5 -19
  63. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
  64. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +61 -44
  65. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  66. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +7 -6
  67. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
  68. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +4 -19
  69. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
  70. package/lib/utilities/Common.styles.js +47 -0
  71. package/lib/utilities/Common.styles.js.map +1 -0
  72. package/lib/utilities/Common.styles.raw.js +47 -0
  73. package/lib/utilities/Common.styles.raw.js.map +1 -0
  74. package/lib/utilities/SVGTooltipText.js.map +1 -1
  75. package/lib/utilities/index.js +1 -0
  76. package/lib/utilities/index.js.map +1 -1
  77. package/lib/utilities/scatterpolar-utils.js +52 -0
  78. package/lib/utilities/scatterpolar-utils.js.map +1 -0
  79. package/lib/utilities/utilities.js +32 -37
  80. package/lib/utilities/utilities.js.map +1 -1
  81. package/lib-commonjs/components/AreaChart/AreaChart.js +4 -1
  82. package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
  83. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
  84. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js +2 -14
  85. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
  86. package/lib-commonjs/components/ChartTable/ChartTable.js +87 -6
  87. package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -1
  88. package/lib-commonjs/components/CommonComponents/CartesianChart.js +24 -24
  89. package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
  90. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +15 -13
  91. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  92. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +4 -32
  93. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
  94. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +41 -15
  95. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  96. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +23 -1
  97. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
  98. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +509 -257
  99. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  100. package/lib-commonjs/components/DonutChart/DonutChart.js +6 -1
  101. package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
  102. package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -1
  103. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js +32 -4
  104. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
  105. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js +8 -4
  106. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
  107. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +22 -3
  108. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  109. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +2 -19
  110. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  111. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +3 -20
  112. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
  113. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +174 -113
  114. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
  115. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +25 -5
  116. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  117. package/lib-commonjs/components/LineChart/LineChart.js +127 -81
  118. package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
  119. package/lib-commonjs/components/LineChart/LineChart.types.js.map +1 -1
  120. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js +30 -9
  121. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  122. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js +2 -20
  123. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
  124. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js +23 -33
  125. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
  126. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.raw.js +1 -12
  127. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.raw.js.map +1 -1
  128. package/lib-commonjs/components/ScatterChart/ScatterChart.js +85 -58
  129. package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
  130. package/lib-commonjs/components/ScatterChart/ScatterChart.types.js.map +1 -1
  131. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js +37 -5
  132. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  133. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js +7 -13
  134. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
  135. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +26 -3
  136. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  137. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +5 -3
  138. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  139. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +3 -17
  140. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
  141. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +60 -43
  142. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  143. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +5 -3
  144. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
  145. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +3 -18
  146. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
  147. package/lib-commonjs/utilities/Common.styles.js +71 -0
  148. package/lib-commonjs/utilities/Common.styles.js.map +1 -0
  149. package/lib-commonjs/utilities/Common.styles.raw.js +71 -0
  150. package/lib-commonjs/utilities/Common.styles.raw.js.map +1 -0
  151. package/lib-commonjs/utilities/SVGTooltipText.js.map +1 -1
  152. package/lib-commonjs/utilities/index.js +1 -0
  153. package/lib-commonjs/utilities/index.js.map +1 -1
  154. package/lib-commonjs/utilities/scatterpolar-utils.js +67 -0
  155. package/lib-commonjs/utilities/scatterpolar-utils.js.map +1 -0
  156. package/lib-commonjs/utilities/utilities.js +28 -40
  157. package/lib-commonjs/utilities/utilities.js.map +1 -1
  158. package/package.json +12 -12
@@ -4,10 +4,12 @@ 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
6
  import { findNumericMinMaxOfY, formatScientificLimitWidth, MIN_DONUT_RADIUS } from '../../utilities/utilities';
7
- import { isArrayOrTypedArray, isDate, isDateArray, isNumberArray, isStringArray, isYearArray, isInvalidValue } from '@fluentui/chart-utilities';
7
+ import { isArrayOrTypedArray, isDate, isDateArray, isNumberArray, isStringArray, isYearArray, isInvalidValue, formatToLocaleString } 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();
@@ -200,7 +243,7 @@ export const transformPlotlyJsonToDonutProps = (input, isMultiPlot, colorMap, co
200
243
  chartTitle,
201
244
  chartData: Object.values(mapLegendToDataPoint)
202
245
  },
203
- hideLegend: ((_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : _input_layout5.showlegend) === false ? true : false,
246
+ hideLegend: isMultiPlot || ((_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : _input_layout5.showlegend) === false,
204
247
  width: (_input_layout6 = input.layout) === null || _input_layout6 === void 0 ? void 0 : _input_layout6.width,
205
248
  height,
206
249
  innerRadius,
@@ -219,17 +262,16 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
219
262
  const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
220
263
  const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
221
264
  let colorScale = undefined;
265
+ const yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
222
266
  let yMinValue = 0;
223
267
  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
- }
268
+ var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _input_layout_template_layout1, _input_layout_template1, _input_layout1, _series_line;
269
+ colorScale = createColorScale(input.layout, series, colorScale);
228
270
  const isXYearCategory = isYearArray(series.x); // Consider year as categorical not numeric continuous axis
229
271
  // 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);
272
+ 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
273
  // 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);
274
+ 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
275
  const xValues = series.x;
234
276
  const isXDate = isDateArray(xValues);
235
277
  const isXString = isStringArray(xValues);
@@ -252,6 +294,7 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
252
294
  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
295
  const opacity = getOpacity(series, index2);
254
296
  const yVal = rangeYValues[index2];
297
+ const yAxisCalloutData = getFormattedCalloutYData(yVal, yAxisTickFormat);
255
298
  if (series.type === 'bar') {
256
299
  var _rgb_copy_formatHex8;
257
300
  mapXToDataPoints[x].chartData.push({
@@ -259,7 +302,8 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
259
302
  data: yVal,
260
303
  color: (_rgb_copy_formatHex8 = rgb(color).copy({
261
304
  opacity
262
- }).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
305
+ }).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
306
+ yAxisCalloutData
263
307
  });
264
308
  if (typeof yVal === 'number') {
265
309
  yMaxValue = Math.max(yMaxValue, yVal);
@@ -281,7 +325,8 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
281
325
  ...lineOptions !== null && lineOptions !== void 0 ? lineOptions : {},
282
326
  mode: series.mode
283
327
  },
284
- useSecondaryYScale: usesSecondaryYScale(series, input.layout)
328
+ useSecondaryYScale: usesSecondaryYScale(series, input.layout),
329
+ yAxisCalloutData
285
330
  });
286
331
  if (!usesSecondaryYScale(series, input.layout) && typeof yVal === 'number') {
287
332
  yMaxValue = Math.max(yMaxValue, yVal);
@@ -292,7 +337,6 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
292
337
  });
293
338
  });
294
339
  });
295
- const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
296
340
  const vsbcData = Object.values(mapXToDataPoints);
297
341
  var _input_layout_height;
298
342
  return {
@@ -302,9 +346,6 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
302
346
  barWidth: 'auto',
303
347
  yMaxValue,
304
348
  yMinValue,
305
- chartTitle,
306
- xAxisTitle,
307
- yAxisTitle,
308
349
  mode: 'plotly',
309
350
  ...secondaryYAxisValues,
310
351
  wrapXAxisLables: typeof ((_vsbcData_ = vsbcData[0]) === null || _vsbcData_ === void 0 ? void 0 : _vsbcData_.xAxisPoint) === 'string',
@@ -314,36 +355,27 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
314
355
  roundCorners: true,
315
356
  showYAxisLables: true,
316
357
  noOfCharsToTruncate: 20,
317
- showYAxisLablesTooltip: true
358
+ showYAxisLablesTooltip: true,
359
+ ...getTitles(input.layout),
360
+ ...getXAxisTickFormat(input.data[0], input.layout),
361
+ ...yAxisTickFormat,
362
+ ...getAxisCategoryOrderProps(input.data, input.layout),
363
+ ...getBarProps(input.data, input.layout),
364
+ ...getYMinMaxValues(input.data[0], input.layout)
318
365
  };
319
366
  };
320
- const createColorScale = (layout, series)=>{
321
- var _layout_coloraxis, _series_marker, _layout_coloraxis1, _layout_coloraxis2;
322
- const scale = layout === null || layout === void 0 ? void 0 : (_layout_coloraxis = layout.coloraxis) === null || _layout_coloraxis === void 0 ? void 0 : _layout_coloraxis.colorscale;
323
- const colorValues = (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color;
324
- var _layout_coloraxis_cmin, _layout_coloraxis_cmax;
325
- const [dMin, dMax] = [
326
- (_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),
327
- (_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)
328
- ];
329
- // Normalize colorscale domain to actual data domain
330
- const scaleDomain = scale.map(([pos])=>dMin + pos * (dMax - dMin));
331
- const scaleColors = scale.map((item)=>item[1]);
332
- return d3ScaleLinear().domain(scaleDomain).range(scaleColors);
333
- };
334
367
  export const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
335
368
  var _input_layout, _input_layout1, _gvbcData_;
336
369
  const mapXToDataPoints = {};
337
370
  const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, 0, 0);
338
371
  const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
339
372
  let colorScale = undefined;
373
+ const yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
340
374
  input.data.forEach((series, index1)=>{
341
- 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;
342
- 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') {
343
- colorScale = createColorScale(input.layout, series);
344
- }
375
+ var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _series_x;
376
+ colorScale = createColorScale(input.layout, series, colorScale);
345
377
  // extract colors for each series only once
346
- 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);
378
+ 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);
347
379
  (_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x.forEach((x, index2)=>{
348
380
  var _series_y;
349
381
  if (isInvalidValue(x) || isInvalidValue((_series_y = series.y) === null || _series_y === void 0 ? void 0 : _series_y[index2])) {
@@ -359,23 +391,24 @@ export const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, col
359
391
  var _series_marker, _series_marker1, _series_marker_color, _series_marker2;
360
392
  const legend = legends[index1];
361
393
  // resolve color for each legend's bars from the colorscale or extracted colors
362
- 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, index1, legend, colorMap, isDarkTheme);
394
+ 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);
363
395
  const opacity = getOpacity(series, index2);
396
+ const yVal = series.y[index2];
364
397
  var _rgb_copy_formatHex8;
365
398
  mapXToDataPoints[x].series.push({
366
399
  key: legend,
367
- data: series.y[index2],
400
+ data: yVal,
368
401
  xAxisCalloutData: x,
369
402
  color: (_rgb_copy_formatHex8 = rgb(color).copy({
370
403
  opacity
371
404
  }).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
372
405
  legend,
373
- useSecondaryYScale: usesSecondaryYScale(series, input.layout)
406
+ useSecondaryYScale: usesSecondaryYScale(series, input.layout),
407
+ yAxisCalloutData: getFormattedCalloutYData(yVal, yAxisTickFormat)
374
408
  });
375
409
  }
376
410
  });
377
411
  });
378
- const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
379
412
  const gvbcData = Object.values(mapXToDataPoints);
380
413
  var _input_layout_height;
381
414
  return {
@@ -383,15 +416,18 @@ export const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, col
383
416
  width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
384
417
  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,
385
418
  barWidth: 'auto',
386
- chartTitle,
387
- xAxisTitle,
388
- yAxisTitle,
389
419
  mode: 'plotly',
390
420
  ...secondaryYAxisValues,
391
421
  hideTickOverlap: true,
392
422
  wrapXAxisLables: typeof ((_gvbcData_ = gvbcData[0]) === null || _gvbcData_ === void 0 ? void 0 : _gvbcData_.name) === 'string',
393
423
  hideLegend,
394
- roundCorners: true
424
+ roundCorners: true,
425
+ ...getTitles(input.layout),
426
+ ...getYMinMaxValues(input.data[0], input.layout),
427
+ ...getXAxisTickFormat(input.data[0], input.layout),
428
+ ...yAxisTickFormat,
429
+ ...getAxisCategoryOrderProps(input.data, input.layout),
430
+ ...getBarProps(input.data, input.layout)
395
431
  };
396
432
  };
397
433
  export const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
@@ -400,15 +436,13 @@ export const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colo
400
436
  const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
401
437
  let colorScale = undefined;
402
438
  input.data.forEach((series, seriesIdx)=>{
403
- 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;
439
+ var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _series_xbins, _series_xbins1, _series_xbins2;
404
440
  if (!series.x) {
405
441
  return;
406
442
  }
407
- 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') {
408
- colorScale = createColorScale(input.layout, series);
409
- }
443
+ colorScale = createColorScale(input.layout, series, colorScale);
410
444
  // extract colors for each series only once
411
- 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);
445
+ 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);
412
446
  const xValues = [];
413
447
  const yValues = [];
414
448
  series.x.forEach((xVal, index)=>{
@@ -457,21 +491,20 @@ export const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colo
457
491
  });
458
492
  });
459
493
  });
460
- const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
461
494
  var _input_layout_height;
462
495
  return {
463
496
  data: vbcData,
464
497
  width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
465
498
  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,
466
- chartTitle,
467
- xAxisTitle,
468
- yAxisTitle,
469
499
  mode: 'histogram',
470
500
  hideTickOverlap: true,
471
501
  wrapXAxisLables: typeof ((_vbcData_ = vbcData[0]) === null || _vbcData_ === void 0 ? void 0 : _vbcData_.x) === 'string',
472
502
  maxBarWidth: 50,
473
503
  hideLegend,
474
- roundCorners: true
504
+ roundCorners: true,
505
+ ...getTitles(input.layout),
506
+ ...getYMinMaxValues(input.data[0], input.layout),
507
+ ...getAxisCategoryOrderProps(input.data, input.layout)
475
508
  };
476
509
  };
477
510
  export const transformPlotlyJsonToAreaChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
@@ -484,19 +517,23 @@ export const transformPlotlyJsonToScatterChartProps = (input, isMultiPlot, color
484
517
  return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'scatter', colorMap, colorwayType, isDarkTheme);
485
518
  };
486
519
  const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme)=>{
487
- var _input_data_;
520
+ var _input_data_, _input_layout, _input_layout1;
488
521
  const isScatterMarkers = [
522
+ 'text',
523
+ 'markers',
489
524
  'text+markers',
490
525
  'markers+text',
491
526
  'lines+markers',
492
527
  'markers+line',
493
- 'text+lines+markers'
528
+ 'text+lines+markers',
529
+ 'lines+markers+text'
494
530
  ].includes((_input_data_ = input.data[0]) === null || _input_data_ === void 0 ? void 0 : _input_data_.mode);
495
531
  const isAreaChart = chartType === 'area';
496
532
  const isScatterChart = chartType === 'scatter';
497
533
  const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
498
534
  let mode = 'tonexty';
499
535
  const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
536
+ const yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
500
537
  const chartData = input.data.map((series, index)=>{
501
538
  var _series_mode, _series_line, _series_marker, _series_line1, _input_layout_template_layout, _input_layout_template, _input_layout, _series_mode1;
502
539
  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;
@@ -512,11 +549,12 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
512
549
  const seriesColor = resolveColor(extractedColors, index, legend, colorMap, isDarkTheme);
513
550
  const seriesOpacity = getOpacity(series, index);
514
551
  mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
515
- const lineOptions = !((_series_mode1 = series.mode) === null || _series_mode1 === void 0 ? void 0 : _series_mode1.includes('text')) ? getLineOptions(series.line) : undefined;
552
+ // if mode contains 'text', we prioritize showing the text over curving the line
553
+ const lineOptions = !((_series_mode1 = series.mode) === null || _series_mode1 === void 0 ? void 0 : _series_mode1.includes('text')) && series.type !== 'scatterpolar' ? getLineOptions(series.line) : undefined;
516
554
  const legendShape = getLegendShape(series);
517
555
  const validXYRanges = getValidXYRanges(series);
518
556
  return validXYRanges.map(([rangeStart, rangeEnd], rangeIdx)=>{
519
- var _series_marker;
557
+ var _series_marker, _input_layout, _input_layout_polar_angularaxis, _input_layout_polar, _input_layout1, _input_layout_polar_angularaxis1, _input_layout_polar1, _input_layout2;
520
558
  const rangeXValues = xValues.slice(rangeStart, rangeEnd);
521
559
  const rangeYValues = series.y.slice(rangeStart, rangeEnd);
522
560
  const markerSizes = isArrayOrTypedArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.size) ? series.marker.size.slice(rangeStart, rangeEnd) : [];
@@ -537,7 +575,8 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
537
575
  } : {},
538
576
  ...textValues ? {
539
577
  text: textValues[i]
540
- } : {}
578
+ } : {},
579
+ yAxisCalloutData: getFormattedCalloutYData(rangeYValues[i], yAxisTickFormat)
541
580
  };
542
581
  }),
543
582
  color: (_rgb_copy_formatHex8 = rgb(seriesColor).copy({
@@ -545,58 +584,59 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
545
584
  }).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : seriesColor,
546
585
  lineOptions: {
547
586
  ...lineOptions !== null && lineOptions !== void 0 ? lineOptions : {},
548
- mode: series.mode
587
+ mode: series.type !== 'scatterpolar' ? series.mode : 'scatterpolar',
588
+ // originXOffset is not typed on Layout, but may be present in input.layout as a part of projection of
589
+ // scatter polar coordingates to cartesian coordinates
590
+ ...series.type === 'scatterpolar' ? {
591
+ originXOffset: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.__polarOriginX,
592
+ 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,
593
+ 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,
594
+ axisLabel: series.__axisLabel ? series.__axisLabel : {}
595
+ } : {}
549
596
  },
550
597
  useSecondaryYScale: usesSecondaryYScale(series, input.layout)
551
598
  };
552
599
  });
553
600
  }).flat();
554
- const yMinMaxValues = findNumericMinMaxOfY(chartData);
555
- const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
601
+ const yMinMax = getYMinMaxValues(input.data[0], input.layout);
602
+ if (yMinMax.yMinValue === undefined && yMinMax.yMaxValue === undefined) {
603
+ const yMinMaxValues = findNumericMinMaxOfY(chartData);
604
+ yMinMax.yMinValue = yMinMaxValues.startValue;
605
+ yMinMax.yMaxValue = yMinMaxValues.endValue;
606
+ }
556
607
  const numDataPoints = chartData.reduce((total, lineChartPoints)=>total + lineChartPoints.data.length, 0);
557
608
  const chartProps = {
558
- chartTitle,
559
609
  lineChartData: chartData
560
610
  };
561
611
  const scatterChartProps = {
562
- chartTitle,
563
612
  scatterChartData: chartData
564
613
  };
614
+ var _input_layout_height;
615
+ const commonProps = {
616
+ supportNegativeData: true,
617
+ ...secondaryYAxisValues,
618
+ width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
619
+ 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,
620
+ hideTickOverlap: true,
621
+ hideLegend,
622
+ useUTC: false,
623
+ optimizeLargeData: numDataPoints > 1000,
624
+ ...getTitles(input.layout),
625
+ ...getXAxisTickFormat(input.data[0], input.layout),
626
+ ...yAxisTickFormat
627
+ };
565
628
  if (isAreaChart) {
566
- var _input_layout, _input_layout1;
567
- var _input_layout_height;
568
629
  return {
569
630
  data: chartProps,
570
- supportNegativeData: true,
571
- xAxisTitle,
572
- yAxisTitle,
573
- ...secondaryYAxisValues,
574
631
  mode,
575
- width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
576
- 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,
577
- hideTickOverlap: true,
578
- useUTC: false,
579
- hideLegend,
580
- optimizeLargeData: numDataPoints > 1000
632
+ ...commonProps
581
633
  };
582
634
  } else {
583
- var _input_layout2, _input_layout3;
584
- var _input_layout_height1;
585
635
  return {
586
636
  data: isScatterChart ? scatterChartProps : chartProps,
587
- supportNegativeData: true,
588
- xAxisTitle,
589
- yAxisTitle,
590
- ...secondaryYAxisValues,
591
637
  roundedTicks: true,
592
- yMinValue: yMinMaxValues.startValue,
593
- yMaxValue: yMinMaxValues.endValue,
594
- width: (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.width,
595
- 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,
596
- hideTickOverlap: true,
597
- useUTC: false,
598
- hideLegend,
599
- optimizeLargeData: numDataPoints > 1000
638
+ ...commonProps,
639
+ ...yMinMax
600
640
  };
601
641
  }
602
642
  };
@@ -605,12 +645,10 @@ export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPl
605
645
  const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
606
646
  let colorScale = undefined;
607
647
  const chartData = input.data.map((series, index)=>{
608
- 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;
609
- 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') {
610
- colorScale = createColorScale(input.layout, series);
611
- }
648
+ var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker;
649
+ colorScale = createColorScale(input.layout, series, colorScale);
612
650
  // extract colors for each series only once
613
- 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);
651
+ 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);
614
652
  const legend = legends[index];
615
653
  return series.y.map((yValue, i)=>{
616
654
  var _series_x, _series_marker, _series_marker1, _series_marker_color, _series_marker2;
@@ -630,8 +668,7 @@ export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPl
630
668
  }).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
631
669
  };
632
670
  }).filter((point)=>point !== null);
633
- }).reverse().flat()//reversing the order to invert the Y bars order as required by plotly.
634
- .reverse();
671
+ }).flat();
635
672
  var _input_layout_height;
636
673
  const chartHeight = (_input_layout_height = (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 450;
637
674
  var _input_layout_margin_l;
@@ -643,12 +680,8 @@ export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPl
643
680
  const scalingFactor = 0.01;
644
681
  const gapFactor = 1 / (1 + scalingFactor * numberOfRows);
645
682
  const barHeight = availableHeight / (numberOfRows * (1 + gapFactor));
646
- const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
647
683
  return {
648
684
  data: chartData,
649
- chartTitle,
650
- xAxisTitle,
651
- yAxisTitle,
652
685
  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) || '',
653
686
  barHeight,
654
687
  showYAxisLables: true,
@@ -658,7 +691,10 @@ export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPl
658
691
  noOfCharsToTruncate: 20,
659
692
  showYAxisLablesTooltip: true,
660
693
  hideLegend,
661
- roundCorners: true
694
+ roundCorners: true,
695
+ ...getTitles(input.layout),
696
+ ...getAxisCategoryOrderProps(input.data, input.layout),
697
+ ...getBarProps(input.data, input.layout, true)
662
698
  };
663
699
  };
664
700
  export const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
@@ -772,7 +808,6 @@ export const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap,
772
808
  }
773
809
  const domainValuesForColorScale = Array.isArray(colorscale) ? colorscale.map((arr)=>arr[0] * (zMax - zMin) + zMin) : defaultDomain;
774
810
  const rangeValuesForColorScale = Array.isArray(colorscale) ? colorscale.map((arr)=>arr[1]) : defaultRange;
775
- const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
776
811
  var _input_layout_height;
777
812
  return {
778
813
  data: [
@@ -782,16 +817,17 @@ export const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap,
782
817
  rangeValuesForColorScale,
783
818
  hideLegend: true,
784
819
  showYAxisLables: true,
785
- chartTitle,
786
- xAxisTitle,
787
- yAxisTitle,
788
820
  sortOrder: 'none',
789
821
  width: (_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : _input_layout5.width,
790
822
  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,
791
823
  hideTickOverlap: true,
792
824
  noOfCharsToTruncate: 20,
793
825
  showYAxisLablesTooltip: true,
794
- wrapXAxisLables: true
826
+ wrapXAxisLables: true,
827
+ ...getTitles(input.layout),
828
+ ...getAxisCategoryOrderProps([
829
+ firstData
830
+ ], input.layout)
795
831
  };
796
832
  };
797
833
  export const transformPlotlyJsonToSankeyProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
@@ -940,7 +976,7 @@ const formatValue = (value, colIndex, cells)=>{
940
976
  return `${prefix !== null && prefix !== void 0 ? prefix : ''}${formatted}${suffix !== null && suffix !== void 0 ? suffix : ''}`;
941
977
  };
942
978
  export const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
943
- 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;
979
+ 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;
944
980
  const tableData = input.data[0];
945
981
  const normalizeHeaders = (values, header)=>{
946
982
  const cleanedValues = Array.isArray(values[0]) ? values.map((row)=>row.map((cell)=>cleanText(cell)).filter(Boolean).join(' ')) : values.map((cell)=>cleanText(cell));
@@ -949,7 +985,8 @@ export const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMa
949
985
  const fontColorRaw = header === null || header === void 0 ? void 0 : (_header_font = header.font) === null || _header_font === void 0 ? void 0 : _header_font.color;
950
986
  let fontColor;
951
987
  if (Array.isArray(fontColorRaw)) {
952
- const colorEntry = fontColorRaw[colIndex];
988
+ var _fontColorRaw_colIndex;
989
+ const colorEntry = (_fontColorRaw_colIndex = fontColorRaw[colIndex]) !== null && _fontColorRaw_colIndex !== void 0 ? _fontColorRaw_colIndex : fontColorRaw[0];
953
990
  if (Array.isArray(colorEntry)) {
954
991
  fontColor = typeof colorEntry[0] === 'string' ? colorEntry[0] : undefined;
955
992
  } else if (typeof colorEntry === 'string') {
@@ -961,15 +998,20 @@ export const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMa
961
998
  const fontSizeRaw = header === null || header === void 0 ? void 0 : (_header_font1 = header.font) === null || _header_font1 === void 0 ? void 0 : _header_font1.size;
962
999
  let fontSize;
963
1000
  if (Array.isArray(fontSizeRaw)) {
964
- fontSize = Array.isArray(fontSizeRaw[0]) ? fontSizeRaw[0][colIndex] : fontSizeRaw[colIndex];
1001
+ var _fontSizeRaw_colIndex;
1002
+ const fontSizeEntry = (_fontSizeRaw_colIndex = fontSizeRaw[colIndex]) !== null && _fontSizeRaw_colIndex !== void 0 ? _fontSizeRaw_colIndex : fontSizeRaw[0];
1003
+ var _fontSizeRaw__colIndex;
1004
+ 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;
965
1005
  } else if (typeof fontSizeRaw === 'number') {
966
1006
  fontSize = fontSizeRaw;
967
1007
  }
968
1008
  const updatedColIndex = colIndex >= 1 ? 1 : 0;
969
1009
  const fillColorRaw = header === null || header === void 0 ? void 0 : (_header_fill = header.fill) === null || _header_fill === void 0 ? void 0 : _header_fill.color;
970
- const backgroundColor = Array.isArray(fillColorRaw) ? fillColorRaw[updatedColIndex] : fillColorRaw;
1010
+ var _fillColorRaw_updatedColIndex;
1011
+ const backgroundColor = Array.isArray(fillColorRaw) ? (_fillColorRaw_updatedColIndex = fillColorRaw[updatedColIndex]) !== null && _fillColorRaw_updatedColIndex !== void 0 ? _fillColorRaw_updatedColIndex : fillColorRaw[0] : fillColorRaw;
971
1012
  const textAlignRaw = header === null || header === void 0 ? void 0 : header.align;
972
- const textAlign = Array.isArray(textAlignRaw) ? textAlignRaw[colIndex] : textAlignRaw;
1013
+ var _textAlignRaw_colIndex;
1014
+ const textAlign = Array.isArray(textAlignRaw) ? (_textAlignRaw_colIndex = textAlignRaw[colIndex]) !== null && _textAlignRaw_colIndex !== void 0 ? _textAlignRaw_colIndex : textAlignRaw[0] : textAlignRaw;
973
1015
  const style = {
974
1016
  ...typeof fontColor === 'string' ? {
975
1017
  color: fontColor
@@ -992,7 +1034,7 @@ export const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMa
992
1034
  };
993
1035
  var _tableData_cells_values;
994
1036
  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 : [];
995
- 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;
1037
+ 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;
996
1038
  const rows = columns[0].map((_, rowIndex)=>columns.map((col, colIndex)=>{
997
1039
  var _cells_font, _cells_font1, _cells_fill;
998
1040
  const cellValue = col[rowIndex];
@@ -1001,7 +1043,8 @@ export const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMa
1001
1043
  const rawFontColor = cells === null || cells === void 0 ? void 0 : (_cells_font = cells.font) === null || _cells_font === void 0 ? void 0 : _cells_font.color;
1002
1044
  let fontColor;
1003
1045
  if (Array.isArray(rawFontColor)) {
1004
- const entry = rawFontColor[colIndex];
1046
+ var _rawFontColor_colIndex;
1047
+ const entry = (_rawFontColor_colIndex = rawFontColor[colIndex]) !== null && _rawFontColor_colIndex !== void 0 ? _rawFontColor_colIndex : rawFontColor[0];
1005
1048
  const colorValue = Array.isArray(entry) ? entry[rowIndex] : entry;
1006
1049
  fontColor = typeof colorValue === 'string' ? colorValue : undefined;
1007
1050
  } else if (typeof rawFontColor === 'string') {
@@ -1010,7 +1053,8 @@ export const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMa
1010
1053
  const rawFontSize = cells === null || cells === void 0 ? void 0 : (_cells_font1 = cells.font) === null || _cells_font1 === void 0 ? void 0 : _cells_font1.size;
1011
1054
  let fontSize;
1012
1055
  if (Array.isArray(rawFontSize)) {
1013
- const entry = rawFontSize[colIndex];
1056
+ var _rawFontSize_colIndex;
1057
+ const entry = (_rawFontSize_colIndex = rawFontSize[colIndex]) !== null && _rawFontSize_colIndex !== void 0 ? _rawFontSize_colIndex : rawFontSize[0];
1014
1058
  const fontSizeValue = Array.isArray(entry) ? entry[rowIndex] : entry;
1015
1059
  fontSize = typeof fontSizeValue === 'number' ? fontSizeValue : undefined;
1016
1060
  } else if (typeof rawFontSize === 'number') {
@@ -1020,13 +1064,15 @@ export const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMa
1020
1064
  const rawBackgroundColor = cells === null || cells === void 0 ? void 0 : (_cells_fill = cells.fill) === null || _cells_fill === void 0 ? void 0 : _cells_fill.color;
1021
1065
  let backgroundColor;
1022
1066
  if (Array.isArray(rawBackgroundColor)) {
1023
- const entry = rawBackgroundColor[updatedColIndex];
1067
+ var _rawBackgroundColor_updatedColIndex;
1068
+ const entry = (_rawBackgroundColor_updatedColIndex = rawBackgroundColor[updatedColIndex]) !== null && _rawBackgroundColor_updatedColIndex !== void 0 ? _rawBackgroundColor_updatedColIndex : rawBackgroundColor[0];
1024
1069
  const colorValue = Array.isArray(entry) ? entry[rowIndex] : entry;
1025
1070
  backgroundColor = typeof colorValue === 'string' ? colorValue : undefined;
1026
1071
  } else if (typeof rawBackgroundColor === 'string') {
1027
1072
  backgroundColor = rawBackgroundColor;
1028
1073
  }
1029
- 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;
1074
+ var _cells_align_colIndex;
1075
+ 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;
1030
1076
  const textAlign = rawTextAlign;
1031
1077
  const style = {
1032
1078
  ...fontColor ? {
@@ -1056,7 +1102,7 @@ export const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMa
1056
1102
  };
1057
1103
  var _tableData_header_values;
1058
1104
  return {
1059
- 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),
1105
+ 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),
1060
1106
  rows,
1061
1107
  width: (_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : _input_layout3.width,
1062
1108
  height: (_input_layout4 = input.layout) === null || _input_layout4 === void 0 ? void 0 : _input_layout4.height,
@@ -1064,27 +1110,141 @@ export const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMa
1064
1110
  };
1065
1111
  };
1066
1112
  export const projectPolarToCartesian = (input)=>{
1113
+ var _input_layout, _input_layout1;
1067
1114
  const projection = {
1068
1115
  ...input
1069
1116
  };
1117
+ // Find the global min and max radius across all series
1118
+ let minRadius = 0;
1119
+ let maxRadius = 0;
1120
+ for(let sindex = 0; sindex < input.data.length; sindex++){
1121
+ const rVals = input.data[sindex].r;
1122
+ if (rVals && isArrayOrTypedArray(rVals)) {
1123
+ for(let ptindex = 0; ptindex < rVals.length; ptindex++){
1124
+ if (!isInvalidValue(rVals[ptindex])) {
1125
+ minRadius = Math.min(minRadius, rVals[ptindex]);
1126
+ maxRadius = Math.max(maxRadius, rVals[ptindex]);
1127
+ }
1128
+ }
1129
+ }
1130
+ }
1131
+ // If there are negative radii, compute the shift
1132
+ const radiusShift = minRadius < 0 ? -minRadius : 0;
1133
+ // Collect all unique theta values from all scatterpolar series for equal spacing
1134
+ const allThetaValues = new Set();
1070
1135
  for(let sindex = 0; sindex < input.data.length; sindex++){
1071
- var _series_r;
1072
1136
  const series = input.data[sindex];
1137
+ if (series.theta && isArrayOrTypedArray(series.theta)) {
1138
+ series.theta.forEach((theta)=>allThetaValues.add(String(theta)));
1139
+ }
1140
+ }
1141
+ // Project all points and create a perfect square domain
1142
+ const allX = [];
1143
+ const allY = [];
1144
+ let originX = null;
1145
+ for(let sindex = 0; sindex < input.data.length; sindex++){
1146
+ var _input_layout_polar_angularaxis, _input_layout_polar, _input_layout2, _input_layout_polar_angularaxis1, _input_layout_polar1, _input_layout3;
1147
+ const series = input.data[sindex];
1148
+ // If scatterpolar, set __axisLabel to all unique theta values for equal spacing
1149
+ if (isArrayOrTypedArray(series.theta)) {
1150
+ series.__axisLabel = Array.from(allThetaValues);
1151
+ }
1073
1152
  series.x = [];
1074
1153
  series.y = [];
1075
- var _series_r_length;
1076
- 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++){
1077
- var _series_theta, _series_r1;
1078
- 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])) {
1154
+ const thetas = series.theta;
1155
+ const rVals = series.r;
1156
+ // Skip if rVals or thetas are not arrays
1157
+ if (!isArrayOrTypedArray(rVals) || !isArrayOrTypedArray(thetas)) {
1158
+ projection.data[sindex] = series;
1159
+ continue;
1160
+ }
1161
+ // retrieve polar axis settings
1162
+ 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;
1163
+ var _input_layout_polar_angularaxis_rotation;
1164
+ 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;
1165
+ // Compute tick positions if categorical
1166
+ let uniqueTheta = [];
1167
+ let categorical = false;
1168
+ if (!isNumberArray(thetas)) {
1169
+ uniqueTheta = Array.from(new Set(thetas));
1170
+ categorical = true;
1171
+ }
1172
+ for(let ptindex = 0; ptindex < rVals.length; ptindex++){
1173
+ if (isInvalidValue(thetas === null || thetas === void 0 ? void 0 : thetas[ptindex]) || isInvalidValue(rVals === null || rVals === void 0 ? void 0 : rVals[ptindex])) {
1079
1174
  continue;
1080
1175
  }
1081
- const thetaRad = series.theta[ptindex] * Math.PI / 180;
1082
- const radius = series.r[ptindex];
1083
- series.x.push(radius * Math.cos(thetaRad));
1084
- series.y.push(radius * Math.sin(thetaRad));
1176
+ // Map theta to angle in radians
1177
+ let thetaRad;
1178
+ if (categorical) {
1179
+ const idx = uniqueTheta.indexOf(thetas[ptindex]);
1180
+ const step = 2 * Math.PI / uniqueTheta.length;
1181
+ thetaRad = startAngleInRad + dirMultiplier * idx * step;
1182
+ } else {
1183
+ thetaRad = startAngleInRad + dirMultiplier * (thetas[ptindex] * Math.PI / 180);
1184
+ }
1185
+ // Shift only the polar origin (not the cartesian)
1186
+ const rawRadius = rVals[ptindex];
1187
+ const polarRadius = rawRadius + radiusShift; // Only for projection
1188
+ // Calculate cartesian coordinates (with shifted polar origin)
1189
+ const x = polarRadius * Math.cos(thetaRad);
1190
+ const y = polarRadius * Math.sin(thetaRad);
1191
+ // Calculate the cartesian coordinates of the original polar origin (0,0)
1192
+ // This is the point that should be mapped to (0,0) in cartesian coordinates
1193
+ if (sindex === 0 && ptindex === 0) {
1194
+ // For polar origin (r=0, θ=0), cartesian coordinates are (0,0)
1195
+ // But since we shifted the radius by radiusShift, the cartesian origin is at (radiusShift, 0)
1196
+ originX = radiusShift;
1197
+ }
1198
+ series.x.push(x);
1199
+ series.y.push(y);
1200
+ allX.push(x);
1201
+ allY.push(y);
1202
+ }
1203
+ // Map text to each data point for downstream chart rendering
1204
+ if (series.x && series.y) {
1205
+ series.data = series.x.map((xVal, idx)=>({
1206
+ x: xVal,
1207
+ y: series.y[idx],
1208
+ ...series.text ? {
1209
+ text: series.text[idx]
1210
+ } : {}
1211
+ }));
1085
1212
  }
1086
1213
  projection.data[sindex] = series;
1087
1214
  }
1215
+ // 7. Recenter all cartesian coordinates
1216
+ if (originX !== null) {
1217
+ for(let sindex = 0; sindex < projection.data.length; sindex++){
1218
+ const series = projection.data[sindex];
1219
+ if (series.x && series.y) {
1220
+ series.x = series.x.map((v)=>v - originX);
1221
+ }
1222
+ }
1223
+ // Also recenter allX for normalization
1224
+ for(let i = 0; i < allX.length; i++){
1225
+ allX[i] = allX[i] - originX;
1226
+ }
1227
+ }
1228
+ // 8. Find the maximum absolute value among all x and y
1229
+ let maxAbs = Math.max(...allX.map(Math.abs), ...allY.map(Math.abs));
1230
+ maxAbs = maxAbs === 0 ? 1 : maxAbs;
1231
+ // 9. Rescale all points so that the largest |x| or |y| is 0.5
1232
+ for(let sindex = 0; sindex < projection.data.length; sindex++){
1233
+ const series = projection.data[sindex];
1234
+ if (series.x && series.y) {
1235
+ series.x = series.x.map((v)=>v / (2 * maxAbs));
1236
+ series.y = series.y.map((v)=>v / (2 * maxAbs));
1237
+ }
1238
+ }
1239
+ // 10. Customize layout for perfect square with absolute positioning
1240
+ 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;
1241
+ projection.layout = {
1242
+ ...projection.layout,
1243
+ width: size,
1244
+ height: size
1245
+ };
1246
+ // Attach originX as custom properties
1247
+ projection.layout.__polarOriginX = originX !== null && originX !== void 0 ? originX : undefined;
1088
1248
  return projection;
1089
1249
  };
1090
1250
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -1264,25 +1424,44 @@ const getLegendShape = (series)=>{
1264
1424
  }
1265
1425
  return 'default';
1266
1426
  };
1267
- export const getAllupLegendsProps = (input, colorMap, colorwayType, isDarkTheme)=>{
1427
+ export const getAllupLegendsProps = (input, colorMap, colorwayType, traceInfo, isDarkTheme)=>{
1268
1428
  const allupLegends = [];
1269
1429
  // reduce on showlegend boolean propperty. reduce should return true if at least one series has showlegend true
1270
1430
  const toShowLegend = input.data.reduce((acc, series)=>{
1271
- return acc || series.showlegend === true;
1431
+ return acc || series.showlegend === true || series.showlegend === undefined;
1272
1432
  }, false);
1273
1433
  if (toShowLegend) {
1274
1434
  input.data.forEach((series, index)=>{
1275
- var _series_line, _series_marker, _input_layout_template_layout, _input_layout_template, _input_layout;
1276
- const name = series.legendgroup;
1277
- 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);
1278
- const legendShape = getLegendShape(series);
1279
- 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);
1280
- if (name !== undefined && allupLegends.some((group)=>group.title === name) === false) {
1281
- allupLegends.push({
1282
- title: name,
1283
- color: resolvedColor,
1284
- shape: legendShape
1435
+ if (traceInfo[index].type === 'donut') {
1436
+ var _input_layout, _input_layout_template_layout, _input_layout_template, _input_layout1, _input_layout2, _pieSeries_marker, _pieSeries_labels;
1437
+ const pieSeries = series;
1438
+ var _input_layout_piecolorway, _input_layout_piecolorway1;
1439
+ 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);
1440
+ (_pieSeries_labels = pieSeries.labels) === null || _pieSeries_labels === void 0 ? void 0 : _pieSeries_labels.forEach((label, labelIndex)=>{
1441
+ const legend = `${label}`;
1442
+ // resolve color for each legend from the extracted colors
1443
+ const color = resolveColor(colors, labelIndex, legend, colorMap, isDarkTheme);
1444
+ if (legend !== '' && allupLegends.some((group)=>group.title === legend) === false) {
1445
+ allupLegends.push({
1446
+ title: legend,
1447
+ color
1448
+ });
1449
+ }
1285
1450
  });
1451
+ } else if (isNonPlotType(traceInfo[index].type) === false) {
1452
+ var _plotSeries_line, _plotSeries_marker, _input_layout_template_layout1, _input_layout_template1, _input_layout3;
1453
+ const plotSeries = series;
1454
+ const name = plotSeries.legendgroup;
1455
+ 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);
1456
+ const legendShape = getLegendShape(plotSeries);
1457
+ 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);
1458
+ if (name !== undefined && name !== '' && allupLegends.some((group)=>group.title === name) === false) {
1459
+ allupLegends.push({
1460
+ title: name,
1461
+ color: resolvedColor,
1462
+ shape: legendShape
1463
+ });
1464
+ }
1286
1465
  }
1287
1466
  });
1288
1467
  }
@@ -1348,28 +1527,21 @@ const getIndexFromKey = (key, pattern)=>{
1348
1527
  const normalizedKey = key.replace(pattern, '') === '' ? '1' : key.replace(pattern, '');
1349
1528
  return parseInt(normalizedKey, 10) - 1;
1350
1529
  };
1351
- export const getGridProperties = (layout, isMultiPlot)=>{
1352
- var _layout_annotations;
1353
- const gridX = [];
1354
- const gridY = [];
1530
+ export const isNonPlotType = (chartType)=>{
1531
+ return [
1532
+ 'donut',
1533
+ 'sankey',
1534
+ 'pie'
1535
+ ].includes(chartType);
1536
+ };
1537
+ export const getGridProperties = (schema, isMultiPlot, validTracesInfo)=>{
1538
+ const domainX = [];
1539
+ const domainY = [];
1540
+ let cartesianDomains = 0;
1355
1541
  const annotations = {};
1356
1542
  let templateRows = '1fr';
1357
1543
  let templateColumns = '1fr';
1358
1544
  const gridLayout = {};
1359
- if (layout === undefined || layout === null || Object.keys(layout).length === 0) {
1360
- return {
1361
- templateRows,
1362
- templateColumns,
1363
- layout: gridLayout
1364
- };
1365
- }
1366
- if (!layout.xaxis || !layout.yaxis) {
1367
- return {
1368
- templateRows,
1369
- templateColumns,
1370
- layout: gridLayout
1371
- };
1372
- }
1373
1545
  if (!isMultiPlot) {
1374
1546
  return {
1375
1547
  templateRows,
@@ -1377,143 +1549,214 @@ export const getGridProperties = (layout, isMultiPlot)=>{
1377
1549
  layout: gridLayout
1378
1550
  };
1379
1551
  }
1380
- Object.keys(layout).forEach((key)=>{
1381
- if (key.startsWith('xaxis')) {
1382
- var _layout_key, _layout_key1;
1383
- const index = getIndexFromKey(key, 'xaxis');
1384
- var _layout_key_anchor;
1385
- 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';
1386
- const anchorIndex = getIndexFromKey(anchor, 'y');
1387
- if (index !== anchorIndex) {
1388
- throw new Error(`Invalid layout: xaxis ${index + 1} anchor should be y${anchorIndex + 1}`);
1389
- }
1390
- var _layout_key_domain;
1391
- 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 : [];
1392
- } else if (key.startsWith('yaxis')) {
1393
- var _layout_key2, _layout_key3;
1394
- const index = getIndexFromKey(key, 'yaxis');
1395
- var _layout_key_anchor1;
1396
- 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';
1397
- const anchorIndex = getIndexFromKey(anchor, 'x');
1398
- if (index !== anchorIndex) {
1399
- var _layout_yaxis2;
1400
- if (index === 1 && anchorIndex === 0 || ((_layout_yaxis2 = layout.yaxis2) === null || _layout_yaxis2 === void 0 ? void 0 : _layout_yaxis2.side) === 'right') {
1401
- // Special case for secondary y axis where yaxis2 can anchor to x1
1402
- return {
1403
- templateRows,
1404
- templateColumns
1405
- };
1552
+ const layout = schema === null || schema === void 0 ? void 0 : schema.layout;
1553
+ if (layout !== undefined && layout !== null && Object.keys(layout).length > 0) {
1554
+ Object.keys(layout !== null && layout !== void 0 ? layout : {}).forEach((key)=>{
1555
+ if (key.startsWith('xaxis')) {
1556
+ var _layout_key;
1557
+ const index = getIndexFromKey(key, 'xaxis');
1558
+ var _layout_key_anchor;
1559
+ 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';
1560
+ const anchorIndex = getIndexFromKey(anchor, 'y');
1561
+ if (index !== anchorIndex) {
1562
+ throw new Error(`Invalid layout: xaxis ${index + 1} anchor should be y${anchorIndex + 1}`);
1406
1563
  }
1407
- throw new Error(`Invalid layout: yaxis ${index + 1} anchor should be x${anchorIndex + 1}`);
1564
+ const xAxisLayout = layout[key];
1565
+ const domainXInfo = {
1566
+ start: (xAxisLayout === null || xAxisLayout === void 0 ? void 0 : xAxisLayout.domain) ? xAxisLayout.domain[0] : 0,
1567
+ end: (xAxisLayout === null || xAxisLayout === void 0 ? void 0 : xAxisLayout.domain) ? xAxisLayout.domain[1] : 1
1568
+ };
1569
+ domainX.push(domainXInfo);
1570
+ } else if (key.startsWith('yaxis')) {
1571
+ var _layout_key1;
1572
+ const index = getIndexFromKey(key, 'yaxis');
1573
+ var _layout_key_anchor1;
1574
+ 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';
1575
+ const anchorIndex = getIndexFromKey(anchor, 'x');
1576
+ if (index !== anchorIndex) {
1577
+ var _layout_yaxis2;
1578
+ if (index === 1 && anchorIndex === 0 || ((_layout_yaxis2 = layout.yaxis2) === null || _layout_yaxis2 === void 0 ? void 0 : _layout_yaxis2.side) === 'right') {
1579
+ // Special case for secondary y axis where yaxis2 can anchor to x1
1580
+ return {
1581
+ templateRows,
1582
+ templateColumns
1583
+ };
1584
+ }
1585
+ throw new Error(`Invalid layout: yaxis ${index + 1} anchor should be x${anchorIndex + 1}`);
1586
+ }
1587
+ const yAxisLayout = layout[key];
1588
+ const domainYInfo = {
1589
+ start: (yAxisLayout === null || yAxisLayout === void 0 ? void 0 : yAxisLayout.domain) ? yAxisLayout.domain[0] : 0,
1590
+ end: (yAxisLayout === null || yAxisLayout === void 0 ? void 0 : yAxisLayout.domain) ? yAxisLayout.domain[1] : 1
1591
+ };
1592
+ domainY.push(domainYInfo);
1408
1593
  }
1409
- var _layout_key_domain1;
1410
- 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 : [];
1594
+ });
1595
+ }
1596
+ cartesianDomains = domainX.length; // Assuming that the number of x and y axes is the same
1597
+ validTracesInfo.forEach((trace, index)=>{
1598
+ if (isNonPlotType(trace.type)) {
1599
+ var _schema_data, _series_domain, _series_domain1, _series_domain2, _series_domain3;
1600
+ const series = schema === null || schema === void 0 ? void 0 : (_schema_data = schema.data) === null || _schema_data === void 0 ? void 0 : _schema_data[index];
1601
+ const domainXInfo = {
1602
+ start: ((_series_domain = series.domain) === null || _series_domain === void 0 ? void 0 : _series_domain.x) ? series.domain.x[0] : 0,
1603
+ end: ((_series_domain1 = series.domain) === null || _series_domain1 === void 0 ? void 0 : _series_domain1.x) ? series.domain.x[1] : 1
1604
+ };
1605
+ const domainYInfo = {
1606
+ start: ((_series_domain2 = series.domain) === null || _series_domain2 === void 0 ? void 0 : _series_domain2.y) ? series.domain.y[0] : 0,
1607
+ end: ((_series_domain3 = series.domain) === null || _series_domain3 === void 0 ? void 0 : _series_domain3.y) ? series.domain.y[1] : 1
1608
+ };
1609
+ domainX.push(domainXInfo);
1610
+ domainY.push(domainYInfo);
1411
1611
  }
1412
1612
  });
1413
- (_layout_annotations = layout.annotations) === null || _layout_annotations === void 0 ? void 0 : _layout_annotations.forEach((annotation)=>{
1414
- 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] ? [
1415
- idx
1416
- ] : []);
1417
- 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]);
1418
- if (yMatch !== -1) {
1419
- if (annotations[yMatch] === undefined) {
1420
- annotations[yMatch] = {};
1421
- }
1422
- if ((annotation === null || annotation === void 0 ? void 0 : annotation.textangle) === 90) {
1423
- annotations[yMatch].yAnnotation = annotation.text;
1424
- } else {
1425
- annotations[yMatch].xAnnotation = annotation.text;
1613
+ if (layout !== undefined && layout !== null && Object.keys(layout).length > 0) {
1614
+ var _layout_annotations;
1615
+ (_layout_annotations = layout.annotations) === null || _layout_annotations === void 0 ? void 0 : _layout_annotations.forEach((annotation)=>{
1616
+ 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 ? [
1617
+ idx
1618
+ ] : []);
1619
+ 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);
1620
+ if (yMatch !== -1) {
1621
+ if (annotations[yMatch] === undefined) {
1622
+ annotations[yMatch] = {};
1623
+ }
1624
+ if ((annotation === null || annotation === void 0 ? void 0 : annotation.textangle) === 90) {
1625
+ annotations[yMatch].yAnnotation = annotation.text;
1626
+ } else {
1627
+ annotations[yMatch].xAnnotation = annotation.text;
1628
+ }
1426
1629
  }
1427
- }
1428
- });
1429
- if (gridX.length > 0) {
1630
+ });
1631
+ }
1632
+ if (domainX.length > 0) {
1430
1633
  const uniqueXIntervals = new Map();
1431
- gridX.forEach((interval)=>{
1432
- const key = `${interval[0]}-${interval[1]}`;
1634
+ domainX.forEach((interval)=>{
1635
+ const key = `${interval.start}-${interval.end}`;
1433
1636
  if (!uniqueXIntervals.has(key)) {
1434
1637
  uniqueXIntervals.set(key, interval);
1435
1638
  }
1436
1639
  });
1437
- const minXInterval = Math.min(...Array.from(uniqueXIntervals.values()).map((interval)=>interval[1] - interval[0]));
1438
- templateColumns = Array.from(uniqueXIntervals.values()).map((interval)=>`${(interval[1] - interval[0]) / minXInterval}fr`).join(' ');
1439
- let columnNumber = 1;
1440
- let lastIntervalEnd = 0;
1441
- gridX.forEach((interval, index)=>{
1442
- if (interval.length === 0) {
1443
- return;
1444
- }
1445
- const cellName = `x${index === 0 ? '' : index + 1}`;
1640
+ const sortedXStart = Array.from(uniqueXIntervals.values()).map((interval)=>interval.start).sort();
1641
+ templateColumns = `repeat(${sortedXStart.length}, 1fr)`;
1642
+ domainX.forEach((interval, index)=>{
1643
+ const cellName = index >= cartesianDomains ? `${NON_PLOT_KEY_PREFIX}${index - cartesianDomains + 1}` : `x${index === 0 ? '' : index + 1}`;
1644
+ const columnIndex = sortedXStart.findIndex((start)=>start === interval.start);
1645
+ const columnNumber = columnIndex + 1; // Column numbers are 1-based
1446
1646
  const annotationProps = annotations[index];
1447
1647
  const xAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.xAnnotation;
1448
- if (interval[0] < lastIntervalEnd) {
1449
- columnNumber = 1;
1450
- }
1451
- lastIntervalEnd = interval[1];
1452
1648
  const row = {
1453
1649
  row: -1,
1454
1650
  column: columnNumber,
1455
- xAnnotation
1651
+ xAnnotation,
1652
+ xDomain: interval,
1653
+ yDomain: {
1654
+ start: 0,
1655
+ end: 1
1656
+ }
1456
1657
  };
1457
1658
  gridLayout[cellName] = row;
1458
- columnNumber += 1;
1459
1659
  });
1460
1660
  }
1461
- const numColumns = Math.max(...Object.values(gridLayout).map((cell)=>{
1462
- var _cell_column;
1463
- return (_cell_column = cell.column) !== null && _cell_column !== void 0 ? _cell_column : 0;
1464
- }));
1465
- const columnFill = {};
1466
- for(let i = 1; i <= numColumns; i++){
1467
- columnFill[i] = {
1468
- row: 1,
1469
- fillDomain: 0
1470
- };
1471
- }
1472
- if (gridY.length > 0) {
1661
+ if (domainY.length > 0) {
1473
1662
  const uniqueYIntervals = new Map();
1474
- gridY.forEach((interval)=>{
1475
- const key = `${interval[0]}-${interval[1]}`;
1663
+ domainY.forEach((interval)=>{
1664
+ const key = `${interval.start}-${interval.end}`;
1476
1665
  if (!uniqueYIntervals.has(key)) {
1477
1666
  uniqueYIntervals.set(key, interval);
1478
1667
  }
1479
1668
  });
1480
- const minYInterval = Math.min(...Array.from(uniqueYIntervals.values()).map((interval)=>interval[1] - interval[0]));
1481
- templateRows = Array.from(uniqueYIntervals.values()).map((interval)=>`${(interval[1] - interval[0]) / minYInterval}fr`).join(' ');
1482
- gridY.forEach((interval, index)=>{
1483
- if (interval.length === 0) {
1484
- return;
1485
- }
1486
- const cellName = `x${index === 0 ? '' : index + 1}`;
1669
+ const sortedYStart = Array.from(uniqueYIntervals.values()).map((interval)=>interval.start).sort();
1670
+ const numberOfRows = sortedYStart.length;
1671
+ templateRows = `repeat(${numberOfRows}, 1fr)`;
1672
+ domainY.forEach((interval, index)=>{
1673
+ const cellName = index >= cartesianDomains ? `${NON_PLOT_KEY_PREFIX}${index - cartesianDomains + 1}` : `x${index === 0 ? '' : index + 1}`;
1674
+ const rowIndex = sortedYStart.findIndex((start)=>start === interval.start);
1675
+ const rowNumber = numberOfRows - rowIndex; // Rows are 1-based and we need to reverse the order for CSS grid
1487
1676
  const annotationProps = annotations[index];
1488
1677
  const yAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.yAnnotation;
1489
1678
  const cell = gridLayout[cellName];
1490
1679
  if (cell !== undefined) {
1491
- cell.row = columnFill[cell.column].row;
1680
+ cell.row = rowNumber;
1492
1681
  cell.yAnnotation = yAnnotation;
1682
+ cell.yDomain = interval;
1493
1683
  }
1494
- columnFill[cell.column].fillDomain = interval[1];
1495
- columnFill[cell.column].row += 1;
1496
1684
  });
1497
1685
  }
1498
- // reverse the order of rows in grid layout from bottom-top to top-bottom as required by CSS grid
1499
- const reversedGridLayout = {};
1500
- // find the maximum row number
1501
- const maxRowNumber = Math.max(...Object.values(gridLayout).map((cell)=>{
1502
- var _cell_row;
1503
- return (_cell_row = cell.row) !== null && _cell_row !== void 0 ? _cell_row : 0;
1504
- }));
1505
- // iterate over the gridLayout and reverse the row numbers
1506
- Object.keys(gridLayout).forEach((key)=>{
1507
- const cell = gridLayout[key];
1508
- if (cell.row !== undefined) {
1509
- // reverse the row number
1510
- cell.row = maxRowNumber - cell.row + 1;
1511
- }
1512
- reversedGridLayout[key] = cell;
1513
- });
1514
1686
  return {
1515
1687
  templateRows,
1516
1688
  templateColumns,
1517
- layout: reversedGridLayout
1689
+ layout: gridLayout
1690
+ };
1691
+ };
1692
+ /**
1693
+ * @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/category_order_defaults.js#L50}
1694
+ */ const getAxisCategoryOrderProps = (data, layout)=>{
1695
+ const result = {};
1696
+ const axesById = {
1697
+ x: layout === null || layout === void 0 ? void 0 : layout.xaxis,
1698
+ y: layout === null || layout === void 0 ? void 0 : layout.yaxis
1699
+ };
1700
+ Object.keys(axesById).forEach((axId)=>{
1701
+ const ax = axesById[axId];
1702
+ const axLetter = axId[0];
1703
+ const propName = `${axLetter}AxisCategoryOrder`;
1704
+ const values = [];
1705
+ data.forEach((series)=>{
1706
+ var _series_axLetter;
1707
+ (_series_axLetter = series[axLetter]) === null || _series_axLetter === void 0 ? void 0 : _series_axLetter.forEach((val)=>{
1708
+ if (!isInvalidValue(val)) {
1709
+ values.push(val);
1710
+ }
1711
+ });
1712
+ });
1713
+ const isAxisTypeCategory = (ax === null || ax === void 0 ? void 0 : ax.type) === 'category' || isStringArray(values) && !isNumberArray(values) && !isDateArray(values);
1714
+ if (!isAxisTypeCategory) {
1715
+ return;
1716
+ }
1717
+ const isValidArray = isArrayOrTypedArray(ax === null || ax === void 0 ? void 0 : ax.categoryarray) && ax.categoryarray.length > 0;
1718
+ if (isValidArray && (!(ax === null || ax === void 0 ? void 0 : ax.categoryorder) || ax.categoryorder === 'array')) {
1719
+ result[propName] = ax.categoryarray;
1720
+ return;
1721
+ }
1722
+ if (!(ax === null || ax === void 0 ? void 0 : ax.categoryorder) || ax.categoryorder === 'trace' || ax.categoryorder === 'array') {
1723
+ const categoriesInTraceOrder = Array.from(new Set(values));
1724
+ result[propName] = categoriesInTraceOrder;
1725
+ return;
1726
+ }
1727
+ result[propName] = ax.categoryorder;
1728
+ });
1729
+ return result;
1730
+ };
1731
+ const getBarProps = (data, layout, isHorizontal)=>{
1732
+ let padding;
1733
+ if (typeof (layout === null || layout === void 0 ? void 0 : layout.bargap) === 'number') {
1734
+ padding = layout.bargap;
1735
+ }
1736
+ const plotlyBarWidths = data.map((series)=>{
1737
+ if (series.type === 'bar' && (isArrayOrTypedArray(series.width) || typeof series.width === 'number')) {
1738
+ return series.width;
1739
+ }
1740
+ return [];
1741
+ }).flat();
1742
+ const maxPlotlyBarWidth = d3Max(plotlyBarWidths);
1743
+ if (typeof maxPlotlyBarWidth === 'number') {
1744
+ padding = 1 - maxPlotlyBarWidth;
1745
+ padding = Math.max(0, Math.min(padding, 1));
1746
+ }
1747
+ if (typeof padding === 'undefined') {
1748
+ return {};
1749
+ }
1750
+ if (isHorizontal) {
1751
+ return {
1752
+ maxBarHeight: 1000,
1753
+ yAxisPadding: padding
1754
+ };
1755
+ }
1756
+ return {
1757
+ barWidth: 'auto',
1758
+ maxBarWidth: 1000,
1759
+ xAxisInnerPadding: padding,
1760
+ xAxisOuterPadding: padding / 2
1518
1761
  };
1519
1762
  };