@fluentui/react-charts 0.0.0-nightly-20250826-2140.1 → 0.0.0-nightly-20250827-0407.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 +493 -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 +137 -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 +95 -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 +63 -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 +500 -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 +136 -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 +94 -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 +78 -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,58 @@ 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
+ } : {}
549
595
  },
550
596
  useSecondaryYScale: usesSecondaryYScale(series, input.layout)
551
597
  };
552
598
  });
553
599
  }).flat();
554
- const yMinMaxValues = findNumericMinMaxOfY(chartData);
555
- const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
600
+ const yMinMax = getYMinMaxValues(input.data[0], input.layout);
601
+ if (yMinMax.yMinValue === undefined && yMinMax.yMaxValue === undefined) {
602
+ const yMinMaxValues = findNumericMinMaxOfY(chartData);
603
+ yMinMax.yMinValue = yMinMaxValues.startValue;
604
+ yMinMax.yMaxValue = yMinMaxValues.endValue;
605
+ }
556
606
  const numDataPoints = chartData.reduce((total, lineChartPoints)=>total + lineChartPoints.data.length, 0);
557
607
  const chartProps = {
558
- chartTitle,
559
608
  lineChartData: chartData
560
609
  };
561
610
  const scatterChartProps = {
562
- chartTitle,
563
611
  scatterChartData: chartData
564
612
  };
613
+ var _input_layout_height;
614
+ const commonProps = {
615
+ supportNegativeData: true,
616
+ ...secondaryYAxisValues,
617
+ width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
618
+ 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,
619
+ hideTickOverlap: true,
620
+ hideLegend,
621
+ useUTC: false,
622
+ optimizeLargeData: numDataPoints > 1000,
623
+ ...getTitles(input.layout),
624
+ ...getXAxisTickFormat(input.data[0], input.layout),
625
+ ...yAxisTickFormat
626
+ };
565
627
  if (isAreaChart) {
566
- var _input_layout, _input_layout1;
567
- var _input_layout_height;
568
628
  return {
569
629
  data: chartProps,
570
- supportNegativeData: true,
571
- xAxisTitle,
572
- yAxisTitle,
573
- ...secondaryYAxisValues,
574
630
  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
631
+ ...commonProps
581
632
  };
582
633
  } else {
583
- var _input_layout2, _input_layout3;
584
- var _input_layout_height1;
585
634
  return {
586
635
  data: isScatterChart ? scatterChartProps : chartProps,
587
- supportNegativeData: true,
588
- xAxisTitle,
589
- yAxisTitle,
590
- ...secondaryYAxisValues,
591
636
  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
637
+ ...commonProps,
638
+ ...yMinMax
600
639
  };
601
640
  }
602
641
  };
@@ -605,12 +644,10 @@ export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPl
605
644
  const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
606
645
  let colorScale = undefined;
607
646
  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
- }
647
+ var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker;
648
+ colorScale = createColorScale(input.layout, series, colorScale);
612
649
  // 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);
650
+ 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
651
  const legend = legends[index];
615
652
  return series.y.map((yValue, i)=>{
616
653
  var _series_x, _series_marker, _series_marker1, _series_marker_color, _series_marker2;
@@ -630,8 +667,7 @@ export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPl
630
667
  }).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
631
668
  };
632
669
  }).filter((point)=>point !== null);
633
- }).reverse().flat()//reversing the order to invert the Y bars order as required by plotly.
634
- .reverse();
670
+ }).flat();
635
671
  var _input_layout_height;
636
672
  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
673
  var _input_layout_margin_l;
@@ -643,12 +679,8 @@ export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPl
643
679
  const scalingFactor = 0.01;
644
680
  const gapFactor = 1 / (1 + scalingFactor * numberOfRows);
645
681
  const barHeight = availableHeight / (numberOfRows * (1 + gapFactor));
646
- const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
647
682
  return {
648
683
  data: chartData,
649
- chartTitle,
650
- xAxisTitle,
651
- yAxisTitle,
652
684
  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
685
  barHeight,
654
686
  showYAxisLables: true,
@@ -658,7 +690,10 @@ export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPl
658
690
  noOfCharsToTruncate: 20,
659
691
  showYAxisLablesTooltip: true,
660
692
  hideLegend,
661
- roundCorners: true
693
+ roundCorners: true,
694
+ ...getTitles(input.layout),
695
+ ...getAxisCategoryOrderProps(input.data, input.layout),
696
+ ...getBarProps(input.data, input.layout, true)
662
697
  };
663
698
  };
664
699
  export const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
@@ -772,7 +807,6 @@ export const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap,
772
807
  }
773
808
  const domainValuesForColorScale = Array.isArray(colorscale) ? colorscale.map((arr)=>arr[0] * (zMax - zMin) + zMin) : defaultDomain;
774
809
  const rangeValuesForColorScale = Array.isArray(colorscale) ? colorscale.map((arr)=>arr[1]) : defaultRange;
775
- const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
776
810
  var _input_layout_height;
777
811
  return {
778
812
  data: [
@@ -782,16 +816,17 @@ export const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap,
782
816
  rangeValuesForColorScale,
783
817
  hideLegend: true,
784
818
  showYAxisLables: true,
785
- chartTitle,
786
- xAxisTitle,
787
- yAxisTitle,
788
819
  sortOrder: 'none',
789
820
  width: (_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : _input_layout5.width,
790
821
  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
822
  hideTickOverlap: true,
792
823
  noOfCharsToTruncate: 20,
793
824
  showYAxisLablesTooltip: true,
794
- wrapXAxisLables: true
825
+ wrapXAxisLables: true,
826
+ ...getTitles(input.layout),
827
+ ...getAxisCategoryOrderProps([
828
+ firstData
829
+ ], input.layout)
795
830
  };
796
831
  };
797
832
  export const transformPlotlyJsonToSankeyProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
@@ -940,7 +975,7 @@ const formatValue = (value, colIndex, cells)=>{
940
975
  return `${prefix !== null && prefix !== void 0 ? prefix : ''}${formatted}${suffix !== null && suffix !== void 0 ? suffix : ''}`;
941
976
  };
942
977
  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;
978
+ 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
979
  const tableData = input.data[0];
945
980
  const normalizeHeaders = (values, header)=>{
946
981
  const cleanedValues = Array.isArray(values[0]) ? values.map((row)=>row.map((cell)=>cleanText(cell)).filter(Boolean).join(' ')) : values.map((cell)=>cleanText(cell));
@@ -949,7 +984,8 @@ export const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMa
949
984
  const fontColorRaw = header === null || header === void 0 ? void 0 : (_header_font = header.font) === null || _header_font === void 0 ? void 0 : _header_font.color;
950
985
  let fontColor;
951
986
  if (Array.isArray(fontColorRaw)) {
952
- const colorEntry = fontColorRaw[colIndex];
987
+ var _fontColorRaw_colIndex;
988
+ const colorEntry = (_fontColorRaw_colIndex = fontColorRaw[colIndex]) !== null && _fontColorRaw_colIndex !== void 0 ? _fontColorRaw_colIndex : fontColorRaw[0];
953
989
  if (Array.isArray(colorEntry)) {
954
990
  fontColor = typeof colorEntry[0] === 'string' ? colorEntry[0] : undefined;
955
991
  } else if (typeof colorEntry === 'string') {
@@ -961,15 +997,20 @@ export const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMa
961
997
  const fontSizeRaw = header === null || header === void 0 ? void 0 : (_header_font1 = header.font) === null || _header_font1 === void 0 ? void 0 : _header_font1.size;
962
998
  let fontSize;
963
999
  if (Array.isArray(fontSizeRaw)) {
964
- fontSize = Array.isArray(fontSizeRaw[0]) ? fontSizeRaw[0][colIndex] : fontSizeRaw[colIndex];
1000
+ var _fontSizeRaw_colIndex;
1001
+ const fontSizeEntry = (_fontSizeRaw_colIndex = fontSizeRaw[colIndex]) !== null && _fontSizeRaw_colIndex !== void 0 ? _fontSizeRaw_colIndex : fontSizeRaw[0];
1002
+ var _fontSizeRaw__colIndex;
1003
+ 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
1004
  } else if (typeof fontSizeRaw === 'number') {
966
1005
  fontSize = fontSizeRaw;
967
1006
  }
968
1007
  const updatedColIndex = colIndex >= 1 ? 1 : 0;
969
1008
  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;
1009
+ var _fillColorRaw_updatedColIndex;
1010
+ const backgroundColor = Array.isArray(fillColorRaw) ? (_fillColorRaw_updatedColIndex = fillColorRaw[updatedColIndex]) !== null && _fillColorRaw_updatedColIndex !== void 0 ? _fillColorRaw_updatedColIndex : fillColorRaw[0] : fillColorRaw;
971
1011
  const textAlignRaw = header === null || header === void 0 ? void 0 : header.align;
972
- const textAlign = Array.isArray(textAlignRaw) ? textAlignRaw[colIndex] : textAlignRaw;
1012
+ var _textAlignRaw_colIndex;
1013
+ const textAlign = Array.isArray(textAlignRaw) ? (_textAlignRaw_colIndex = textAlignRaw[colIndex]) !== null && _textAlignRaw_colIndex !== void 0 ? _textAlignRaw_colIndex : textAlignRaw[0] : textAlignRaw;
973
1014
  const style = {
974
1015
  ...typeof fontColor === 'string' ? {
975
1016
  color: fontColor
@@ -992,7 +1033,7 @@ export const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMa
992
1033
  };
993
1034
  var _tableData_cells_values;
994
1035
  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;
1036
+ 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
1037
  const rows = columns[0].map((_, rowIndex)=>columns.map((col, colIndex)=>{
997
1038
  var _cells_font, _cells_font1, _cells_fill;
998
1039
  const cellValue = col[rowIndex];
@@ -1001,7 +1042,8 @@ export const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMa
1001
1042
  const rawFontColor = cells === null || cells === void 0 ? void 0 : (_cells_font = cells.font) === null || _cells_font === void 0 ? void 0 : _cells_font.color;
1002
1043
  let fontColor;
1003
1044
  if (Array.isArray(rawFontColor)) {
1004
- const entry = rawFontColor[colIndex];
1045
+ var _rawFontColor_colIndex;
1046
+ const entry = (_rawFontColor_colIndex = rawFontColor[colIndex]) !== null && _rawFontColor_colIndex !== void 0 ? _rawFontColor_colIndex : rawFontColor[0];
1005
1047
  const colorValue = Array.isArray(entry) ? entry[rowIndex] : entry;
1006
1048
  fontColor = typeof colorValue === 'string' ? colorValue : undefined;
1007
1049
  } else if (typeof rawFontColor === 'string') {
@@ -1010,7 +1052,8 @@ export const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMa
1010
1052
  const rawFontSize = cells === null || cells === void 0 ? void 0 : (_cells_font1 = cells.font) === null || _cells_font1 === void 0 ? void 0 : _cells_font1.size;
1011
1053
  let fontSize;
1012
1054
  if (Array.isArray(rawFontSize)) {
1013
- const entry = rawFontSize[colIndex];
1055
+ var _rawFontSize_colIndex;
1056
+ const entry = (_rawFontSize_colIndex = rawFontSize[colIndex]) !== null && _rawFontSize_colIndex !== void 0 ? _rawFontSize_colIndex : rawFontSize[0];
1014
1057
  const fontSizeValue = Array.isArray(entry) ? entry[rowIndex] : entry;
1015
1058
  fontSize = typeof fontSizeValue === 'number' ? fontSizeValue : undefined;
1016
1059
  } else if (typeof rawFontSize === 'number') {
@@ -1020,13 +1063,15 @@ export const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMa
1020
1063
  const rawBackgroundColor = cells === null || cells === void 0 ? void 0 : (_cells_fill = cells.fill) === null || _cells_fill === void 0 ? void 0 : _cells_fill.color;
1021
1064
  let backgroundColor;
1022
1065
  if (Array.isArray(rawBackgroundColor)) {
1023
- const entry = rawBackgroundColor[updatedColIndex];
1066
+ var _rawBackgroundColor_updatedColIndex;
1067
+ const entry = (_rawBackgroundColor_updatedColIndex = rawBackgroundColor[updatedColIndex]) !== null && _rawBackgroundColor_updatedColIndex !== void 0 ? _rawBackgroundColor_updatedColIndex : rawBackgroundColor[0];
1024
1068
  const colorValue = Array.isArray(entry) ? entry[rowIndex] : entry;
1025
1069
  backgroundColor = typeof colorValue === 'string' ? colorValue : undefined;
1026
1070
  } else if (typeof rawBackgroundColor === 'string') {
1027
1071
  backgroundColor = rawBackgroundColor;
1028
1072
  }
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;
1073
+ var _cells_align_colIndex;
1074
+ 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
1075
  const textAlign = rawTextAlign;
1031
1076
  const style = {
1032
1077
  ...fontColor ? {
@@ -1056,7 +1101,7 @@ export const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMa
1056
1101
  };
1057
1102
  var _tableData_header_values;
1058
1103
  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),
1104
+ 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
1105
  rows,
1061
1106
  width: (_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : _input_layout3.width,
1062
1107
  height: (_input_layout4 = input.layout) === null || _input_layout4 === void 0 ? void 0 : _input_layout4.height,
@@ -1064,27 +1109,133 @@ export const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMa
1064
1109
  };
1065
1110
  };
1066
1111
  export const projectPolarToCartesian = (input)=>{
1112
+ var _input_layout, _input_layout1;
1067
1113
  const projection = {
1068
1114
  ...input
1069
1115
  };
1116
+ // 1. Find the global min and max radius across all series
1117
+ let minRadius = 0;
1118
+ let maxRadius = 0;
1119
+ for(let sindex = 0; sindex < input.data.length; sindex++){
1120
+ const rVals = input.data[sindex].r;
1121
+ if (rVals && isArrayOrTypedArray(rVals)) {
1122
+ for(let ptindex = 0; ptindex < rVals.length; ptindex++){
1123
+ if (!isInvalidValue(rVals[ptindex])) {
1124
+ minRadius = Math.min(minRadius, rVals[ptindex]);
1125
+ maxRadius = Math.max(maxRadius, rVals[ptindex]);
1126
+ }
1127
+ }
1128
+ }
1129
+ }
1130
+ // 2. If there are negative radii, compute the shift
1131
+ const radiusShift = minRadius < 0 ? -minRadius : 0;
1132
+ // 3. Project all points and create a perfect square domain
1133
+ const allX = [];
1134
+ const allY = [];
1135
+ let originX = null;
1070
1136
  for(let sindex = 0; sindex < input.data.length; sindex++){
1071
- var _series_r;
1137
+ var _input_layout_polar_angularaxis, _input_layout_polar, _input_layout2, _input_layout_polar_angularaxis1, _input_layout_polar1, _input_layout3;
1072
1138
  const series = input.data[sindex];
1139
+ // If scatterpolar, set text to theta values as strings
1140
+ if (series.type === 'scatterpolar' && Array.isArray(series.theta)) {
1141
+ series.text = series.theta.map((v)=>String(v));
1142
+ }
1073
1143
  series.x = [];
1074
1144
  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])) {
1145
+ const thetas = series.theta;
1146
+ const rVals = series.r;
1147
+ // Skip if rVals or thetas are not arrays
1148
+ if (!isArrayOrTypedArray(rVals) || !isArrayOrTypedArray(thetas)) {
1149
+ projection.data[sindex] = series;
1150
+ continue;
1151
+ }
1152
+ // retrieve polar axis settings
1153
+ 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;
1154
+ var _input_layout_polar_angularaxis_rotation;
1155
+ 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;
1156
+ // Compute tick positions if categorical
1157
+ let uniqueTheta = [];
1158
+ let categorical = false;
1159
+ if (!isNumberArray(thetas)) {
1160
+ uniqueTheta = Array.from(new Set(thetas));
1161
+ categorical = true;
1162
+ }
1163
+ for(let ptindex = 0; ptindex < rVals.length; ptindex++){
1164
+ if (isInvalidValue(thetas === null || thetas === void 0 ? void 0 : thetas[ptindex]) || isInvalidValue(rVals === null || rVals === void 0 ? void 0 : rVals[ptindex])) {
1079
1165
  continue;
1080
1166
  }
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));
1167
+ // 4. Map theta to angle in radians
1168
+ let thetaRad;
1169
+ if (categorical) {
1170
+ const idx = uniqueTheta.indexOf(thetas[ptindex]);
1171
+ const step = 2 * Math.PI / uniqueTheta.length;
1172
+ thetaRad = startAngleInRad + dirMultiplier * idx * step;
1173
+ } else {
1174
+ thetaRad = startAngleInRad + dirMultiplier * (thetas[ptindex] * Math.PI / 180);
1175
+ }
1176
+ // 5. Shift only the polar origin (not the cartesian)
1177
+ const rawRadius = rVals[ptindex];
1178
+ const polarRadius = rawRadius + radiusShift; // Only for projection
1179
+ // 6. Calculate cartesian coordinates (with shifted polar origin)
1180
+ const x = polarRadius * Math.cos(thetaRad);
1181
+ const y = polarRadius * Math.sin(thetaRad);
1182
+ // Calculate the cartesian coordinates of the original polar origin (0,0)
1183
+ // This is the point that should be mapped to (0,0) in cartesian coordinates
1184
+ if (sindex === 0 && ptindex === 0) {
1185
+ // For polar origin (r=0, θ=0), cartesian coordinates are (0,0)
1186
+ // But since we shifted the radius by radiusShift, the cartesian origin is at (radiusShift, 0)
1187
+ originX = radiusShift;
1188
+ }
1189
+ series.x.push(x);
1190
+ series.y.push(y);
1191
+ allX.push(x);
1192
+ allY.push(y);
1193
+ }
1194
+ // Map text to each data point for downstream chart rendering
1195
+ if (series.x && series.y) {
1196
+ series.data = series.x.map((xVal, idx)=>({
1197
+ x: xVal,
1198
+ y: series.y[idx],
1199
+ ...series.text ? {
1200
+ text: series.text[idx]
1201
+ } : {}
1202
+ }));
1085
1203
  }
1086
1204
  projection.data[sindex] = series;
1087
1205
  }
1206
+ // 7. Recenter all cartesian coordinates
1207
+ if (originX !== null) {
1208
+ for(let sindex = 0; sindex < projection.data.length; sindex++){
1209
+ const series = projection.data[sindex];
1210
+ if (series.x && series.y) {
1211
+ series.x = series.x.map((v)=>v - originX);
1212
+ }
1213
+ }
1214
+ // Also recenter allX for normalization
1215
+ for(let i = 0; i < allX.length; i++){
1216
+ allX[i] = allX[i] - originX;
1217
+ }
1218
+ }
1219
+ // 8. Find the maximum absolute value among all x and y
1220
+ let maxAbs = Math.max(...allX.map(Math.abs), ...allY.map(Math.abs));
1221
+ maxAbs = maxAbs === 0 ? 1 : maxAbs;
1222
+ // 9. Rescale all points so that the largest |x| or |y| is 0.5
1223
+ for(let sindex = 0; sindex < projection.data.length; sindex++){
1224
+ const series = projection.data[sindex];
1225
+ if (series.x && series.y) {
1226
+ series.x = series.x.map((v)=>v / (2 * maxAbs));
1227
+ series.y = series.y.map((v)=>v / (2 * maxAbs));
1228
+ }
1229
+ }
1230
+ // 10. Customize layout for perfect square with absolute positioning
1231
+ 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;
1232
+ projection.layout = {
1233
+ ...projection.layout,
1234
+ width: size,
1235
+ height: size
1236
+ };
1237
+ // Attach originX as custom properties
1238
+ projection.layout.__polarOriginX = originX !== null && originX !== void 0 ? originX : undefined;
1088
1239
  return projection;
1089
1240
  };
1090
1241
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -1264,25 +1415,44 @@ const getLegendShape = (series)=>{
1264
1415
  }
1265
1416
  return 'default';
1266
1417
  };
1267
- export const getAllupLegendsProps = (input, colorMap, colorwayType, isDarkTheme)=>{
1418
+ export const getAllupLegendsProps = (input, colorMap, colorwayType, traceInfo, isDarkTheme)=>{
1268
1419
  const allupLegends = [];
1269
1420
  // reduce on showlegend boolean propperty. reduce should return true if at least one series has showlegend true
1270
1421
  const toShowLegend = input.data.reduce((acc, series)=>{
1271
- return acc || series.showlegend === true;
1422
+ return acc || series.showlegend === true || series.showlegend === undefined;
1272
1423
  }, false);
1273
1424
  if (toShowLegend) {
1274
1425
  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
1426
+ if (traceInfo[index].type === 'donut') {
1427
+ var _input_layout, _input_layout_template_layout, _input_layout_template, _input_layout1, _input_layout2, _pieSeries_marker, _pieSeries_labels;
1428
+ const pieSeries = series;
1429
+ var _input_layout_piecolorway, _input_layout_piecolorway1;
1430
+ 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);
1431
+ (_pieSeries_labels = pieSeries.labels) === null || _pieSeries_labels === void 0 ? void 0 : _pieSeries_labels.forEach((label, labelIndex)=>{
1432
+ const legend = `${label}`;
1433
+ // resolve color for each legend from the extracted colors
1434
+ const color = resolveColor(colors, labelIndex, legend, colorMap, isDarkTheme);
1435
+ if (legend !== '' && allupLegends.some((group)=>group.title === legend) === false) {
1436
+ allupLegends.push({
1437
+ title: legend,
1438
+ color
1439
+ });
1440
+ }
1285
1441
  });
1442
+ } else if (isNonPlotType(traceInfo[index].type) === false) {
1443
+ var _plotSeries_line, _plotSeries_marker, _input_layout_template_layout1, _input_layout_template1, _input_layout3;
1444
+ const plotSeries = series;
1445
+ const name = plotSeries.legendgroup;
1446
+ 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);
1447
+ const legendShape = getLegendShape(plotSeries);
1448
+ 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);
1449
+ if (name !== undefined && name !== '' && allupLegends.some((group)=>group.title === name) === false) {
1450
+ allupLegends.push({
1451
+ title: name,
1452
+ color: resolvedColor,
1453
+ shape: legendShape
1454
+ });
1455
+ }
1286
1456
  }
1287
1457
  });
1288
1458
  }
@@ -1348,28 +1518,21 @@ const getIndexFromKey = (key, pattern)=>{
1348
1518
  const normalizedKey = key.replace(pattern, '') === '' ? '1' : key.replace(pattern, '');
1349
1519
  return parseInt(normalizedKey, 10) - 1;
1350
1520
  };
1351
- export const getGridProperties = (layout, isMultiPlot)=>{
1352
- var _layout_annotations;
1353
- const gridX = [];
1354
- const gridY = [];
1521
+ export const isNonPlotType = (chartType)=>{
1522
+ return [
1523
+ 'donut',
1524
+ 'sankey',
1525
+ 'pie'
1526
+ ].includes(chartType);
1527
+ };
1528
+ export const getGridProperties = (schema, isMultiPlot, validTracesInfo)=>{
1529
+ const domainX = [];
1530
+ const domainY = [];
1531
+ let cartesianDomains = 0;
1355
1532
  const annotations = {};
1356
1533
  let templateRows = '1fr';
1357
1534
  let templateColumns = '1fr';
1358
1535
  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
1536
  if (!isMultiPlot) {
1374
1537
  return {
1375
1538
  templateRows,
@@ -1377,143 +1540,214 @@ export const getGridProperties = (layout, isMultiPlot)=>{
1377
1540
  layout: gridLayout
1378
1541
  };
1379
1542
  }
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
- };
1543
+ const layout = schema === null || schema === void 0 ? void 0 : schema.layout;
1544
+ if (layout !== undefined && layout !== null && Object.keys(layout).length > 0) {
1545
+ Object.keys(layout !== null && layout !== void 0 ? layout : {}).forEach((key)=>{
1546
+ if (key.startsWith('xaxis')) {
1547
+ var _layout_key;
1548
+ const index = getIndexFromKey(key, 'xaxis');
1549
+ var _layout_key_anchor;
1550
+ 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';
1551
+ const anchorIndex = getIndexFromKey(anchor, 'y');
1552
+ if (index !== anchorIndex) {
1553
+ throw new Error(`Invalid layout: xaxis ${index + 1} anchor should be y${anchorIndex + 1}`);
1554
+ }
1555
+ const xAxisLayout = layout[key];
1556
+ const domainXInfo = {
1557
+ start: (xAxisLayout === null || xAxisLayout === void 0 ? void 0 : xAxisLayout.domain) ? xAxisLayout.domain[0] : 0,
1558
+ end: (xAxisLayout === null || xAxisLayout === void 0 ? void 0 : xAxisLayout.domain) ? xAxisLayout.domain[1] : 1
1559
+ };
1560
+ domainX.push(domainXInfo);
1561
+ } else if (key.startsWith('yaxis')) {
1562
+ var _layout_key1;
1563
+ const index = getIndexFromKey(key, 'yaxis');
1564
+ var _layout_key_anchor1;
1565
+ 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';
1566
+ const anchorIndex = getIndexFromKey(anchor, 'x');
1567
+ if (index !== anchorIndex) {
1568
+ var _layout_yaxis2;
1569
+ if (index === 1 && anchorIndex === 0 || ((_layout_yaxis2 = layout.yaxis2) === null || _layout_yaxis2 === void 0 ? void 0 : _layout_yaxis2.side) === 'right') {
1570
+ // Special case for secondary y axis where yaxis2 can anchor to x1
1571
+ return {
1572
+ templateRows,
1573
+ templateColumns
1574
+ };
1575
+ }
1576
+ throw new Error(`Invalid layout: yaxis ${index + 1} anchor should be x${anchorIndex + 1}`);
1406
1577
  }
1407
- throw new Error(`Invalid layout: yaxis ${index + 1} anchor should be x${anchorIndex + 1}`);
1578
+ const yAxisLayout = layout[key];
1579
+ const domainYInfo = {
1580
+ start: (yAxisLayout === null || yAxisLayout === void 0 ? void 0 : yAxisLayout.domain) ? yAxisLayout.domain[0] : 0,
1581
+ end: (yAxisLayout === null || yAxisLayout === void 0 ? void 0 : yAxisLayout.domain) ? yAxisLayout.domain[1] : 1
1582
+ };
1583
+ domainY.push(domainYInfo);
1408
1584
  }
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 : [];
1585
+ });
1586
+ }
1587
+ cartesianDomains = domainX.length; // Assuming that the number of x and y axes is the same
1588
+ validTracesInfo.forEach((trace, index)=>{
1589
+ if (isNonPlotType(trace.type)) {
1590
+ var _schema_data, _series_domain, _series_domain1, _series_domain2, _series_domain3;
1591
+ const series = schema === null || schema === void 0 ? void 0 : (_schema_data = schema.data) === null || _schema_data === void 0 ? void 0 : _schema_data[index];
1592
+ const domainXInfo = {
1593
+ start: ((_series_domain = series.domain) === null || _series_domain === void 0 ? void 0 : _series_domain.x) ? series.domain.x[0] : 0,
1594
+ end: ((_series_domain1 = series.domain) === null || _series_domain1 === void 0 ? void 0 : _series_domain1.x) ? series.domain.x[1] : 1
1595
+ };
1596
+ const domainYInfo = {
1597
+ start: ((_series_domain2 = series.domain) === null || _series_domain2 === void 0 ? void 0 : _series_domain2.y) ? series.domain.y[0] : 0,
1598
+ end: ((_series_domain3 = series.domain) === null || _series_domain3 === void 0 ? void 0 : _series_domain3.y) ? series.domain.y[1] : 1
1599
+ };
1600
+ domainX.push(domainXInfo);
1601
+ domainY.push(domainYInfo);
1411
1602
  }
1412
1603
  });
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;
1604
+ if (layout !== undefined && layout !== null && Object.keys(layout).length > 0) {
1605
+ var _layout_annotations;
1606
+ (_layout_annotations = layout.annotations) === null || _layout_annotations === void 0 ? void 0 : _layout_annotations.forEach((annotation)=>{
1607
+ 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 ? [
1608
+ idx
1609
+ ] : []);
1610
+ 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);
1611
+ if (yMatch !== -1) {
1612
+ if (annotations[yMatch] === undefined) {
1613
+ annotations[yMatch] = {};
1614
+ }
1615
+ if ((annotation === null || annotation === void 0 ? void 0 : annotation.textangle) === 90) {
1616
+ annotations[yMatch].yAnnotation = annotation.text;
1617
+ } else {
1618
+ annotations[yMatch].xAnnotation = annotation.text;
1619
+ }
1426
1620
  }
1427
- }
1428
- });
1429
- if (gridX.length > 0) {
1621
+ });
1622
+ }
1623
+ if (domainX.length > 0) {
1430
1624
  const uniqueXIntervals = new Map();
1431
- gridX.forEach((interval)=>{
1432
- const key = `${interval[0]}-${interval[1]}`;
1625
+ domainX.forEach((interval)=>{
1626
+ const key = `${interval.start}-${interval.end}`;
1433
1627
  if (!uniqueXIntervals.has(key)) {
1434
1628
  uniqueXIntervals.set(key, interval);
1435
1629
  }
1436
1630
  });
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}`;
1631
+ const sortedXStart = Array.from(uniqueXIntervals.values()).map((interval)=>interval.start).sort();
1632
+ templateColumns = `repeat(${sortedXStart.length}, 1fr)`;
1633
+ domainX.forEach((interval, index)=>{
1634
+ const cellName = index >= cartesianDomains ? `${NON_PLOT_KEY_PREFIX}${index - cartesianDomains + 1}` : `x${index === 0 ? '' : index + 1}`;
1635
+ const columnIndex = sortedXStart.findIndex((start)=>start === interval.start);
1636
+ const columnNumber = columnIndex + 1; // Column numbers are 1-based
1446
1637
  const annotationProps = annotations[index];
1447
1638
  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
1639
  const row = {
1453
1640
  row: -1,
1454
1641
  column: columnNumber,
1455
- xAnnotation
1642
+ xAnnotation,
1643
+ xDomain: interval,
1644
+ yDomain: {
1645
+ start: 0,
1646
+ end: 1
1647
+ }
1456
1648
  };
1457
1649
  gridLayout[cellName] = row;
1458
- columnNumber += 1;
1459
1650
  });
1460
1651
  }
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) {
1652
+ if (domainY.length > 0) {
1473
1653
  const uniqueYIntervals = new Map();
1474
- gridY.forEach((interval)=>{
1475
- const key = `${interval[0]}-${interval[1]}`;
1654
+ domainY.forEach((interval)=>{
1655
+ const key = `${interval.start}-${interval.end}`;
1476
1656
  if (!uniqueYIntervals.has(key)) {
1477
1657
  uniqueYIntervals.set(key, interval);
1478
1658
  }
1479
1659
  });
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}`;
1660
+ const sortedYStart = Array.from(uniqueYIntervals.values()).map((interval)=>interval.start).sort();
1661
+ const numberOfRows = sortedYStart.length;
1662
+ templateRows = `repeat(${numberOfRows}, 1fr)`;
1663
+ domainY.forEach((interval, index)=>{
1664
+ const cellName = index >= cartesianDomains ? `${NON_PLOT_KEY_PREFIX}${index - cartesianDomains + 1}` : `x${index === 0 ? '' : index + 1}`;
1665
+ const rowIndex = sortedYStart.findIndex((start)=>start === interval.start);
1666
+ const rowNumber = numberOfRows - rowIndex; // Rows are 1-based and we need to reverse the order for CSS grid
1487
1667
  const annotationProps = annotations[index];
1488
1668
  const yAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.yAnnotation;
1489
1669
  const cell = gridLayout[cellName];
1490
1670
  if (cell !== undefined) {
1491
- cell.row = columnFill[cell.column].row;
1671
+ cell.row = rowNumber;
1492
1672
  cell.yAnnotation = yAnnotation;
1673
+ cell.yDomain = interval;
1493
1674
  }
1494
- columnFill[cell.column].fillDomain = interval[1];
1495
- columnFill[cell.column].row += 1;
1496
1675
  });
1497
1676
  }
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
1677
  return {
1515
1678
  templateRows,
1516
1679
  templateColumns,
1517
- layout: reversedGridLayout
1680
+ layout: gridLayout
1681
+ };
1682
+ };
1683
+ /**
1684
+ * @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/category_order_defaults.js#L50}
1685
+ */ const getAxisCategoryOrderProps = (data, layout)=>{
1686
+ const result = {};
1687
+ const axesById = {
1688
+ x: layout === null || layout === void 0 ? void 0 : layout.xaxis,
1689
+ y: layout === null || layout === void 0 ? void 0 : layout.yaxis
1690
+ };
1691
+ Object.keys(axesById).forEach((axId)=>{
1692
+ const ax = axesById[axId];
1693
+ const axLetter = axId[0];
1694
+ const propName = `${axLetter}AxisCategoryOrder`;
1695
+ const values = [];
1696
+ data.forEach((series)=>{
1697
+ var _series_axLetter;
1698
+ (_series_axLetter = series[axLetter]) === null || _series_axLetter === void 0 ? void 0 : _series_axLetter.forEach((val)=>{
1699
+ if (!isInvalidValue(val)) {
1700
+ values.push(val);
1701
+ }
1702
+ });
1703
+ });
1704
+ const isAxisTypeCategory = (ax === null || ax === void 0 ? void 0 : ax.type) === 'category' || isStringArray(values) && !isNumberArray(values) && !isDateArray(values);
1705
+ if (!isAxisTypeCategory) {
1706
+ return;
1707
+ }
1708
+ const isValidArray = isArrayOrTypedArray(ax === null || ax === void 0 ? void 0 : ax.categoryarray) && ax.categoryarray.length > 0;
1709
+ if (isValidArray && (!(ax === null || ax === void 0 ? void 0 : ax.categoryorder) || ax.categoryorder === 'array')) {
1710
+ result[propName] = ax.categoryarray;
1711
+ return;
1712
+ }
1713
+ if (!(ax === null || ax === void 0 ? void 0 : ax.categoryorder) || ax.categoryorder === 'trace' || ax.categoryorder === 'array') {
1714
+ const categoriesInTraceOrder = Array.from(new Set(values));
1715
+ result[propName] = categoriesInTraceOrder;
1716
+ return;
1717
+ }
1718
+ result[propName] = ax.categoryorder;
1719
+ });
1720
+ return result;
1721
+ };
1722
+ const getBarProps = (data, layout, isHorizontal)=>{
1723
+ let padding;
1724
+ if (typeof (layout === null || layout === void 0 ? void 0 : layout.bargap) === 'number') {
1725
+ padding = layout.bargap;
1726
+ }
1727
+ const plotlyBarWidths = data.map((series)=>{
1728
+ if (series.type === 'bar' && (isArrayOrTypedArray(series.width) || typeof series.width === 'number')) {
1729
+ return series.width;
1730
+ }
1731
+ return [];
1732
+ }).flat();
1733
+ const maxPlotlyBarWidth = d3Max(plotlyBarWidths);
1734
+ if (typeof maxPlotlyBarWidth === 'number') {
1735
+ padding = 1 - maxPlotlyBarWidth;
1736
+ padding = Math.max(0, Math.min(padding, 1));
1737
+ }
1738
+ if (typeof padding === 'undefined') {
1739
+ return {};
1740
+ }
1741
+ if (isHorizontal) {
1742
+ return {
1743
+ maxBarHeight: 1000,
1744
+ yAxisPadding: padding
1745
+ };
1746
+ }
1747
+ return {
1748
+ barWidth: 'auto',
1749
+ maxBarWidth: 1000,
1750
+ xAxisInnerPadding: padding,
1751
+ xAxisOuterPadding: padding / 2
1518
1752
  };
1519
1753
  };