@fluentui/react-charts 0.0.0-nightly-20250819-0407.1 → 0.0.0-nightly-20250821-0406.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 (135) hide show
  1. package/CHANGELOG.md +15 -15
  2. package/dist/index.d.ts +9 -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 -1
  6. package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
  7. package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js +2 -1
  8. package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
  9. package/lib/components/CommonComponents/CartesianChart.js +48 -3
  10. package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
  11. package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
  12. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +13 -0
  13. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  14. package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +12 -0
  15. package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
  16. package/lib/components/DeclarativeChart/DeclarativeChart.js +175 -120
  17. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  18. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +6 -1
  19. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
  20. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +346 -52
  21. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  22. package/lib/components/GanttChart/useGanttChartStyles.styles.js +2 -1
  23. package/lib/components/GanttChart/useGanttChartStyles.styles.js.map +1 -1
  24. package/lib/components/GanttChart/useGanttChartStyles.styles.raw.js +2 -1
  25. package/lib/components/GanttChart/useGanttChartStyles.styles.raw.js.map +1 -1
  26. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +23 -4
  27. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  28. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +2 -1
  29. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  30. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +2 -1
  31. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
  32. package/lib/components/HeatMapChart/HeatMapChart.js +175 -114
  33. package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
  34. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js +2 -1
  35. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
  36. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +2 -1
  37. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.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/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +2 -1
  41. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
  42. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +2 -1
  43. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
  44. package/lib/components/LineChart/useLineChartStyles.styles.js +2 -1
  45. package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  46. package/lib/components/LineChart/useLineChartStyles.styles.raw.js +2 -1
  47. package/lib/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
  48. package/lib/components/ScatterChart/ScatterChart.js +49 -30
  49. package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
  50. package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -1
  51. package/lib/components/ScatterChart/useScatterChartStyles.styles.js +21 -4
  52. package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  53. package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js +16 -3
  54. package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
  55. package/lib/components/VerticalBarChart/VerticalBarChart.js +27 -4
  56. package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  57. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +2 -1
  58. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  59. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +2 -1
  60. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
  61. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +61 -44
  62. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  63. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +2 -1
  64. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
  65. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +2 -1
  66. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
  67. package/lib/utilities/utilities.js +0 -29
  68. package/lib/utilities/utilities.js.map +1 -1
  69. package/lib-commonjs/components/AreaChart/AreaChart.js +4 -1
  70. package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
  71. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js +2 -1
  72. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
  73. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js +2 -1
  74. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
  75. package/lib-commonjs/components/CommonComponents/CartesianChart.js +48 -3
  76. package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
  77. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
  78. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +13 -0
  79. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  80. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +12 -0
  81. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
  82. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +171 -118
  83. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  84. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +9 -1
  85. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
  86. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +362 -58
  87. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  88. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js +2 -1
  89. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js.map +1 -1
  90. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.raw.js +2 -1
  91. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.raw.js.map +1 -1
  92. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +22 -3
  93. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  94. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +2 -1
  95. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  96. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +2 -1
  97. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
  98. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +174 -113
  99. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
  100. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js +2 -1
  101. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
  102. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +2 -1
  103. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
  104. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +25 -5
  105. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  106. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +2 -1
  107. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
  108. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +2 -1
  109. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
  110. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js +2 -1
  111. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  112. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js +2 -1
  113. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
  114. package/lib-commonjs/components/ScatterChart/ScatterChart.js +49 -30
  115. package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
  116. package/lib-commonjs/components/ScatterChart/ScatterChart.types.js.map +1 -1
  117. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js +30 -3
  118. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  119. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js +15 -2
  120. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
  121. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +26 -3
  122. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  123. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +2 -1
  124. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  125. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +2 -1
  126. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
  127. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +60 -43
  128. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  129. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +2 -1
  130. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
  131. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +2 -1
  132. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
  133. package/lib-commonjs/utilities/utilities.js +0 -32
  134. package/lib-commonjs/utilities/utilities.js.map +1 -1
  135. package/package.json +12 -12
@@ -4,9 +4,10 @@ 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 { isArrayOfType, isArrayOrTypedArray, isDate, isDateArray, isNumberArray, isYearArray, isInvalidValue } from '@fluentui/chart-utilities';
7
+ import { isArrayOrTypedArray, isDate, isDateArray, isNumberArray, isStringArray, isYearArray, isInvalidValue } from '@fluentui/chart-utilities';
8
8
  import { curveCardinal as d3CurveCardinal } from 'd3-shape';
9
- import { extractColor, resolveColor } from './PlotlyColorAdapter';
9
+ import { getOpacity, extractColor, resolveColor } from './PlotlyColorAdapter';
10
+ import { rgb } from 'd3-color';
10
11
  const dashOptions = {
11
12
  dot: {
12
13
  strokeDasharray: '1, 5',
@@ -91,8 +92,9 @@ export const correctYearMonth = (xValues)=>{
91
92
  });
92
93
  return xValues;
93
94
  };
94
- const usesSecondaryYScale = (series)=>{
95
- return series.yaxis === 'y2';
95
+ const usesSecondaryYScale = (series, layout)=>{
96
+ var _layout_yaxis2, _layout_yaxis21;
97
+ return series.yaxis === 'y2' && ((layout === null || layout === void 0 ? void 0 : (_layout_yaxis2 = layout.yaxis2) === null || _layout_yaxis2 === void 0 ? void 0 : _layout_yaxis2.anchor) === 'x' || (layout === null || layout === void 0 ? void 0 : (_layout_yaxis21 = layout.yaxis2) === null || _layout_yaxis21 === void 0 ? void 0 : _layout_yaxis21.side) === 'right');
96
98
  };
97
99
  const getSecondaryYAxisValues = (data, layout, maxAllowedMinY, minAllowedMaxY)=>{
98
100
  var _layout_yaxis2, _layout_yaxis21, _layout_yaxis2_title, _layout_yaxis22;
@@ -100,7 +102,7 @@ const getSecondaryYAxisValues = (data, layout, maxAllowedMinY, minAllowedMaxY)=>
100
102
  let yMinValue;
101
103
  let yMaxValue;
102
104
  data.forEach((series)=>{
103
- if (usesSecondaryYScale(series)) {
105
+ if (usesSecondaryYScale(series, layout)) {
104
106
  containsSecondaryYAxis = true;
105
107
  const yValues = series.y;
106
108
  if (yValues) {
@@ -153,7 +155,7 @@ export const resolveXAxisPoint = (x, isXYearCategory, isXString, isXDate, isXNum
153
155
  }
154
156
  return x;
155
157
  };
156
- export const transformPlotlyJsonToDonutProps = (input, colorMap, colorwayType, isDarkTheme)=>{
158
+ export const transformPlotlyJsonToDonutProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
157
159
  var _input_layout, _input_layout_template_layout, _input_layout_template, _input_layout1, _input_layout2, _firstData_marker, _firstData_labels, _input_layout3, _input_layout4, _input_layout5, _input_layout6;
158
160
  const firstData = input.data[0];
159
161
  var _input_layout_piecolorway, _input_layout_piecolorway1;
@@ -210,12 +212,12 @@ export const transformPlotlyJsonToDonutProps = (input, colorMap, colorwayType, i
210
212
  roundCorners: true
211
213
  };
212
214
  };
213
- export const transformPlotlyJsonToVSBCProps = (input, colorMap, colorwayType, isDarkTheme, fallbackVSBC)=>{
215
+ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme, fallbackVSBC)=>{
214
216
  var _input_layout, _input_layout1, _vsbcData_;
215
217
  const mapXToDataPoints = {};
216
218
  let yMaxValue = 0;
217
219
  const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
218
- const { legends, hideLegend } = getLegendProps(input.data, input.layout);
220
+ const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
219
221
  let colorScale = undefined;
220
222
  let yMinValue = 0;
221
223
  input.data.forEach((series, index1)=>{
@@ -248,34 +250,40 @@ export const transformPlotlyJsonToVSBCProps = (input, colorMap, colorwayType, is
248
250
  const legend = legends[index1];
249
251
  // resolve color for each legend's bars from the colorscale or extracted colors
250
252
  const color = colorScale ? colorScale(isArrayOrTypedArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) ? (_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[index2 % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : resolveColor(extractedBarColors, index2, legend, colorMap, isDarkTheme);
253
+ const opacity = getOpacity(series, index2);
251
254
  const yVal = rangeYValues[index2];
252
255
  if (series.type === 'bar') {
256
+ var _rgb_copy_formatHex8;
253
257
  mapXToDataPoints[x].chartData.push({
254
258
  legend,
255
259
  data: yVal,
256
- color
260
+ color: (_rgb_copy_formatHex8 = rgb(color).copy({
261
+ opacity
262
+ }).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
257
263
  });
258
264
  if (typeof yVal === 'number') {
259
265
  yMaxValue = Math.max(yMaxValue, yVal);
260
266
  }
261
267
  } else if (series.type === 'scatter' || !!fallbackVSBC) {
262
- var _series_mode, _series_line, _series_mode1;
268
+ var _series_mode;
263
269
  const lineColor = resolveColor(extractedLineColors, index1, legend, colorMap, isDarkTheme);
264
270
  const lineOptions = !((_series_mode = series.mode) === null || _series_mode === void 0 ? void 0 : _series_mode.includes('text')) ? getLineOptions(series.line) : undefined;
265
- const dashType = ((_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.dash) || 'solid';
266
- const legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot' ? 'dottedLine' : ((_series_mode1 = series.mode) === null || _series_mode1 === void 0 ? void 0 : _series_mode1.includes('markers')) ? 'circle' : 'default';
271
+ const legendShape = getLegendShape(series);
272
+ var _rgb_copy_formatHex81;
267
273
  mapXToDataPoints[x].lineData.push({
268
274
  legend: legend + (validXYRanges.length > 1 ? `.${rangeIdx + 1}` : ''),
269
275
  legendShape,
270
276
  y: yVal,
271
- color: lineColor,
277
+ color: (_rgb_copy_formatHex81 = rgb(lineColor).copy({
278
+ opacity
279
+ }).formatHex8()) !== null && _rgb_copy_formatHex81 !== void 0 ? _rgb_copy_formatHex81 : color,
272
280
  lineOptions: {
273
281
  ...lineOptions !== null && lineOptions !== void 0 ? lineOptions : {},
274
282
  mode: series.mode
275
283
  },
276
- useSecondaryYScale: usesSecondaryYScale(series)
284
+ useSecondaryYScale: usesSecondaryYScale(series, input.layout)
277
285
  });
278
- if (!usesSecondaryYScale(series) && typeof yVal === 'number') {
286
+ if (!usesSecondaryYScale(series, input.layout) && typeof yVal === 'number') {
279
287
  yMaxValue = Math.max(yMaxValue, yVal);
280
288
  yMinValue = Math.min(yMinValue, yVal);
281
289
  }
@@ -306,7 +314,8 @@ export const transformPlotlyJsonToVSBCProps = (input, colorMap, colorwayType, is
306
314
  roundCorners: true,
307
315
  showYAxisLables: true,
308
316
  noOfCharsToTruncate: 20,
309
- showYAxisLablesTooltip: true
317
+ showYAxisLablesTooltip: true,
318
+ ...getAxisCategoryOrderProps(input.data, input.layout)
310
319
  };
311
320
  };
312
321
  const createColorScale = (layout, series)=>{
@@ -323,11 +332,11 @@ const createColorScale = (layout, series)=>{
323
332
  const scaleColors = scale.map((item)=>item[1]);
324
333
  return d3ScaleLinear().domain(scaleDomain).range(scaleColors);
325
334
  };
326
- export const transformPlotlyJsonToGVBCProps = (input, colorMap, colorwayType, isDarkTheme)=>{
335
+ export const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
327
336
  var _input_layout, _input_layout1, _gvbcData_;
328
337
  const mapXToDataPoints = {};
329
338
  const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, 0, 0);
330
- const { legends, hideLegend } = getLegendProps(input.data, input.layout);
339
+ const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
331
340
  let colorScale = undefined;
332
341
  input.data.forEach((series, index1)=>{
333
342
  var _input_layout_coloraxis_colorscale, _input_layout_coloraxis, _input_layout, _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout1, _series_marker3, _series_x;
@@ -351,14 +360,18 @@ export const transformPlotlyJsonToGVBCProps = (input, colorMap, colorwayType, is
351
360
  var _series_marker, _series_marker1, _series_marker_color, _series_marker2;
352
361
  const legend = legends[index1];
353
362
  // resolve color for each legend's bars from the colorscale or extracted colors
354
- 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);
363
+ const color = colorScale ? colorScale(isArrayOrTypedArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) ? (_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[index2 % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : resolveColor(extractedColors, index2, legend, colorMap, isDarkTheme);
364
+ const opacity = getOpacity(series, index2);
365
+ var _rgb_copy_formatHex8;
355
366
  mapXToDataPoints[x].series.push({
356
367
  key: legend,
357
368
  data: series.y[index2],
358
369
  xAxisCalloutData: x,
359
- color,
370
+ color: (_rgb_copy_formatHex8 = rgb(color).copy({
371
+ opacity
372
+ }).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
360
373
  legend,
361
- useSecondaryYScale: usesSecondaryYScale(series)
374
+ useSecondaryYScale: usesSecondaryYScale(series, input.layout)
362
375
  });
363
376
  }
364
377
  });
@@ -379,13 +392,14 @@ export const transformPlotlyJsonToGVBCProps = (input, colorMap, colorwayType, is
379
392
  hideTickOverlap: true,
380
393
  wrapXAxisLables: typeof ((_gvbcData_ = gvbcData[0]) === null || _gvbcData_ === void 0 ? void 0 : _gvbcData_.name) === 'string',
381
394
  hideLegend,
382
- roundCorners: true
395
+ roundCorners: true,
396
+ ...getAxisCategoryOrderProps(input.data, input.layout)
383
397
  };
384
398
  };
385
- export const transformPlotlyJsonToVBCProps = (input, colorMap, colorwayType, isDarkTheme)=>{
399
+ export const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
386
400
  var _input_layout, _input_layout1, _vbcData_;
387
401
  const vbcData = [];
388
- const { legends, hideLegend } = getLegendProps(input.data, input.layout);
402
+ const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
389
403
  let colorScale = undefined;
390
404
  input.data.forEach((series, seriesIdx)=>{
391
405
  var _input_layout_coloraxis_colorscale, _input_layout_coloraxis, _input_layout, _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout1, _series_marker3, _series_xbins, _series_xbins1, _series_xbins2;
@@ -429,12 +443,16 @@ export const transformPlotlyJsonToVBCProps = (input, colorMap, colorwayType, isD
429
443
  const legend = legends[seriesIdx];
430
444
  // resolve color for each legend's bars from the colorscale or extracted colors
431
445
  const color = colorScale ? colorScale(isArrayOrTypedArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) ? (_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[index % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : resolveColor(extractedColors, index, legend, colorMap, isDarkTheme);
446
+ const opacity = getOpacity(series, index);
432
447
  const yVal = calculateHistNorm(series.histnorm, y[index], total, isXString ? bin.length : getBinSize(bin));
448
+ var _rgb_copy_formatHex8;
433
449
  vbcData.push({
434
450
  x: isXString ? bin.join(', ') : getBinCenter(bin),
435
451
  y: yVal,
436
452
  legend,
437
- color,
453
+ color: (_rgb_copy_formatHex8 = rgb(color).copy({
454
+ opacity
455
+ }).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
438
456
  ...isXString ? {} : {
439
457
  xAxisCalloutData: `[${bin.x0} - ${bin.x1})`
440
458
  }
@@ -455,17 +473,36 @@ export const transformPlotlyJsonToVBCProps = (input, colorMap, colorwayType, isD
455
473
  wrapXAxisLables: typeof ((_vbcData_ = vbcData[0]) === null || _vbcData_ === void 0 ? void 0 : _vbcData_.x) === 'string',
456
474
  maxBarWidth: 50,
457
475
  hideLegend,
458
- roundCorners: true
476
+ roundCorners: true,
477
+ ...getAxisCategoryOrderProps(input.data, input.layout)
459
478
  };
460
479
  };
461
- export const transformPlotlyJsonToScatterChartProps = (input, chartType, isScatterMarkers, colorMap, colorwayType, isDarkTheme)=>{
480
+ export const transformPlotlyJsonToAreaChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
481
+ return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'area', colorMap, colorwayType, isDarkTheme);
482
+ };
483
+ export const transformPlotlyJsonToLineChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
484
+ return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'line', colorMap, colorwayType, isDarkTheme);
485
+ };
486
+ export const transformPlotlyJsonToScatterChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
487
+ return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'scatter', colorMap, colorwayType, isDarkTheme);
488
+ };
489
+ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme)=>{
490
+ var _input_data_;
491
+ const isScatterMarkers = [
492
+ 'markers',
493
+ 'text+markers',
494
+ 'markers+text',
495
+ 'lines+markers',
496
+ 'markers+line',
497
+ 'text+lines+markers'
498
+ ].includes((_input_data_ = input.data[0]) === null || _input_data_ === void 0 ? void 0 : _input_data_.mode);
462
499
  const isAreaChart = chartType === 'area';
463
500
  const isScatterChart = chartType === 'scatter';
464
501
  const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
465
502
  let mode = 'tonexty';
466
- const { legends, hideLegend } = getLegendProps(input.data, input.layout);
503
+ const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
467
504
  const chartData = input.data.map((series, index)=>{
468
- var _series_mode, _series_line, _series_marker, _series_line1, _input_layout_template_layout, _input_layout_template, _input_layout, _series_mode1, _series_line2, _series_mode2;
505
+ var _series_mode, _series_line, _series_marker, _series_line1, _input_layout_template_layout, _input_layout_template, _input_layout, _series_mode1;
469
506
  const colors = isScatterMarkers ? (series === null || series === void 0 ? void 0 : (_series_mode = series.mode) === null || _series_mode === void 0 ? void 0 : _series_mode.includes('line')) ? (_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.color : (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color : (_series_line1 = series.line) === null || _series_line1 === void 0 ? void 0 : _series_line1.color;
470
507
  // extract colors for each series only once
471
508
  const extractedColors = extractColor((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, colors, colorMap, isDarkTheme);
@@ -477,10 +514,10 @@ export const transformPlotlyJsonToScatterChartProps = (input, chartType, isScatt
477
514
  const legend = legends[index];
478
515
  // resolve color for each legend's lines from the extracted colors
479
516
  const seriesColor = resolveColor(extractedColors, index, legend, colorMap, isDarkTheme);
517
+ const seriesOpacity = getOpacity(series, index);
480
518
  mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
481
519
  const lineOptions = !((_series_mode1 = series.mode) === null || _series_mode1 === void 0 ? void 0 : _series_mode1.includes('text')) ? getLineOptions(series.line) : undefined;
482
- const dashType = ((_series_line2 = series.line) === null || _series_line2 === void 0 ? void 0 : _series_line2.dash) || 'solid';
483
- const legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot' ? 'dottedLine' : ((_series_mode2 = series.mode) === null || _series_mode2 === void 0 ? void 0 : _series_mode2.includes('markers')) ? 'circle' : 'default';
520
+ const legendShape = getLegendShape(series);
484
521
  const validXYRanges = getValidXYRanges(series);
485
522
  return validXYRanges.map(([rangeStart, rangeEnd], rangeIdx)=>{
486
523
  var _series_marker;
@@ -488,6 +525,7 @@ export const transformPlotlyJsonToScatterChartProps = (input, chartType, isScatt
488
525
  const rangeYValues = series.y.slice(rangeStart, rangeEnd);
489
526
  const markerSizes = isArrayOrTypedArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.size) ? series.marker.size.slice(rangeStart, rangeEnd) : [];
490
527
  const textValues = Array.isArray(series.text) ? series.text.slice(rangeStart, rangeEnd) : undefined;
528
+ var _rgb_copy_formatHex8;
491
529
  return {
492
530
  legend,
493
531
  legendShape,
@@ -506,12 +544,14 @@ export const transformPlotlyJsonToScatterChartProps = (input, chartType, isScatt
506
544
  } : {}
507
545
  };
508
546
  }),
509
- color: seriesColor,
547
+ color: (_rgb_copy_formatHex8 = rgb(seriesColor).copy({
548
+ opacity: seriesOpacity
549
+ }).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : seriesColor,
510
550
  lineOptions: {
511
551
  ...lineOptions !== null && lineOptions !== void 0 ? lineOptions : {},
512
552
  mode: series.mode
513
553
  },
514
- useSecondaryYScale: usesSecondaryYScale(series)
554
+ useSecondaryYScale: usesSecondaryYScale(series, input.layout)
515
555
  };
516
556
  });
517
557
  }).flat();
@@ -564,9 +604,9 @@ export const transformPlotlyJsonToScatterChartProps = (input, chartType, isScatt
564
604
  };
565
605
  }
566
606
  };
567
- export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, colorMap, colorwayType, isDarkTheme)=>{
607
+ export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
568
608
  var _input_layout, _input_layout_margin, _input_layout1, _input_layout_margin1, _input_layout2, _input_layout_yaxis2, _input_layout3, _input_layout_yaxis21, _input_layout4, _input_layout_yaxis2_title, _input_layout_yaxis22, _input_layout5, _input_layout6;
569
- const { legends, hideLegend } = getLegendProps(input.data, input.layout);
609
+ const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
570
610
  let colorScale = undefined;
571
611
  const chartData = input.data.map((series, index)=>{
572
612
  var _input_layout_coloraxis_colorscale, _input_layout_coloraxis, _input_layout, _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout1, _series_marker3;
@@ -583,15 +623,18 @@ export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, colorMap,
583
623
  }
584
624
  // resolve color for each legend's bars from the colorscale or extracted colors
585
625
  const color = colorScale ? colorScale(isArrayOrTypedArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) ? (_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[i % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : resolveColor(extractedColors, i, legend, colorMap, isDarkTheme);
626
+ const opacity = getOpacity(series, i);
627
+ var _rgb_copy_formatHex8;
586
628
  return {
587
629
  x: series.x[i],
588
630
  y: yValue,
589
631
  legend,
590
- color
632
+ color: (_rgb_copy_formatHex8 = rgb(color).copy({
633
+ opacity
634
+ }).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
591
635
  };
592
636
  }).filter((point)=>point !== null);
593
- }).reverse().flat()//reversing the order to invert the Y bars order as required by plotly.
594
- .reverse();
637
+ }).flat();
595
638
  var _input_layout_height;
596
639
  const chartHeight = (_input_layout_height = (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 450;
597
640
  var _input_layout_margin_l;
@@ -618,10 +661,11 @@ export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, colorMap,
618
661
  noOfCharsToTruncate: 20,
619
662
  showYAxisLablesTooltip: true,
620
663
  hideLegend,
621
- roundCorners: true
664
+ roundCorners: true,
665
+ ...getAxisCategoryOrderProps(input.data, input.layout)
622
666
  };
623
667
  };
624
- export const transformPlotlyJsonToHeatmapProps = (input)=>{
668
+ export const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
625
669
  var _input_layout, _input_layout_coloraxis, _input_layout1, _input_layout_template_layout, _input_layout_template, _input_layout2, _input_layout_template_data_histogram2d_, _input_layout_template_data_histogram2d, _input_layout_template_data, _input_layout_template1, _input_layout3, _input_layout_template_data_heatmap_, _input_layout_template_data_heatmap, _input_layout_template_data1, _input_layout_template2, _input_layout4, _input_layout5, _input_layout6;
626
670
  const firstData = input.data[0];
627
671
  const heatmapDataPoints = [];
@@ -751,10 +795,13 @@ export const transformPlotlyJsonToHeatmapProps = (input)=>{
751
795
  hideTickOverlap: true,
752
796
  noOfCharsToTruncate: 20,
753
797
  showYAxisLablesTooltip: true,
754
- wrapXAxisLables: true
798
+ wrapXAxisLables: true,
799
+ ...getAxisCategoryOrderProps([
800
+ firstData
801
+ ], input.layout)
755
802
  };
756
803
  };
757
- export const transformPlotlyJsonToSankeyProps = (input, colorMap, colorwayType, isDarkTheme)=>{
804
+ export const transformPlotlyJsonToSankeyProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
758
805
  var _input_layout_template_layout, _input_layout_template, _input_layout, _node_label, _input_layout1, _input_layout2;
759
806
  const { link, node } = input.data[0];
760
807
  var _link_value;
@@ -803,7 +850,7 @@ export const transformPlotlyJsonToSankeyProps = (input, colorMap, colorwayType,
803
850
  height: (_input_layout_height = (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 468
804
851
  };
805
852
  };
806
- export const transformPlotlyJsonToGaugeProps = (input, colorMap, colorwayType, isDarkTheme)=>{
853
+ export const transformPlotlyJsonToGaugeProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
807
854
  var _firstData_gauge, _input_layout_template_layout, _input_layout_template, _input_layout, _firstData_gauge_steps, _firstData_gauge1, _firstData_gauge_axis_range, _firstData_gauge_axis, _firstData_gauge2, _input_layout_template_layout1, _input_layout_template1, _input_layout1, _firstData_gauge_axis1, _firstData_gauge3, _firstData_gauge_axis_range1, _firstData_gauge_axis2, _firstData_gauge4, _firstData_delta, _firstData_gauge_axis_range2, _firstData_gauge_axis3, _firstData_gauge5, _firstData_gauge_axis_range3, _firstData_gauge_axis4, _firstData_gauge6, _firstData_gauge_axis_range4, _firstData_gauge_axis5, _firstData_gauge7, _firstData_gauge_axis_range5, _firstData_gauge_axis6, _firstData_gauge8, _input_layout2, _input_layout3, _firstData_gauge_steps1, _firstData_gauge9;
808
855
  const firstData = input.data[0];
809
856
  const stepsColors = ((_firstData_gauge = firstData.gauge) === null || _firstData_gauge === void 0 ? void 0 : _firstData_gauge.steps) ? firstData.gauge.steps.map((step)=>step.color) : undefined;
@@ -899,7 +946,7 @@ const formatValue = (value, colIndex, cells)=>{
899
946
  }
900
947
  return `${prefix !== null && prefix !== void 0 ? prefix : ''}${formatted}${suffix !== null && suffix !== void 0 ? suffix : ''}`;
901
948
  };
902
- export const transformPlotlyJsonToChartTableProps = (input, colorMap, isDarkTheme)=>{
949
+ export const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
903
950
  var _tableData_cells, _input_layout_template_data, _input_layout_template, _input_layout, _input_layout_font, _input_layout1, _tableData_header, _tableData_header1, _input_layout_template_data1, _input_layout_template1, _input_layout2, _input_layout3, _input_layout4;
904
951
  const tableData = input.data[0];
905
952
  const normalizeHeaders = (values, header)=>{
@@ -1120,11 +1167,6 @@ function getLineOptions(line) {
1120
1167
  }
1121
1168
  return Object.keys(lineOptions).length > 0 ? lineOptions : undefined;
1122
1169
  }
1123
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1124
- export const isStringArray = (arr)=>{
1125
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1126
- return isArrayOfType(arr, (value)=>typeof value === 'string' || value === null);
1127
- };
1128
1170
  // TODO: Use binary search to find the appropriate bin for numeric value.
1129
1171
  const findBinIndex = (bins, value, isString)=>{
1130
1172
  if (typeof value === 'undefined' || value === null) {
@@ -1219,7 +1261,46 @@ const precisionRound = (value, precision)=>{
1219
1261
  const factor = Math.pow(10, precision);
1220
1262
  return Math.round(value * factor) / factor;
1221
1263
  };
1222
- const getLegendProps = (data, layout)=>{
1264
+ const getLegendShape = (series)=>{
1265
+ var _series_line, _series_mode;
1266
+ const dashType = ((_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.dash) || 'solid';
1267
+ if (dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot') {
1268
+ return 'dottedLine';
1269
+ } else if ((_series_mode = series.mode) === null || _series_mode === void 0 ? void 0 : _series_mode.includes('markers')) {
1270
+ return 'circle';
1271
+ }
1272
+ return 'default';
1273
+ };
1274
+ export const getAllupLegendsProps = (input, colorMap, colorwayType, isDarkTheme)=>{
1275
+ const allupLegends = [];
1276
+ // reduce on showlegend boolean propperty. reduce should return true if at least one series has showlegend true
1277
+ const toShowLegend = input.data.reduce((acc, series)=>{
1278
+ return acc || series.showlegend === true;
1279
+ }, false);
1280
+ if (toShowLegend) {
1281
+ input.data.forEach((series, index)=>{
1282
+ var _series_line, _series_marker, _input_layout_template_layout, _input_layout_template, _input_layout;
1283
+ const name = series.legendgroup;
1284
+ const color = ((_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.color) || ((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color);
1285
+ const legendShape = getLegendShape(series);
1286
+ const resolvedColor = extractColor((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, color, colorMap, isDarkTheme);
1287
+ if (name !== undefined && allupLegends.some((group)=>group.title === name) === false) {
1288
+ allupLegends.push({
1289
+ title: name,
1290
+ color: resolvedColor,
1291
+ shape: legendShape
1292
+ });
1293
+ }
1294
+ });
1295
+ }
1296
+ return {
1297
+ legends: allupLegends,
1298
+ centerLegends: true,
1299
+ enabledWrapLines: true,
1300
+ canSelectMultipleLegends: true
1301
+ };
1302
+ };
1303
+ const getLegendProps = (data, layout, isMultiPlot)=>{
1223
1304
  const legends = [];
1224
1305
  if (data.length === 1) {
1225
1306
  legends.push(data[0].name || '');
@@ -1228,10 +1309,11 @@ const getLegendProps = (data, layout)=>{
1228
1309
  legends.push(series.name || `Series ${index + 1}`);
1229
1310
  });
1230
1311
  }
1231
- const hideLegends = data.every((series)=>series.showlegend === false);
1312
+ const hideLegendsData = data.every((series)=>series.showlegend === false);
1313
+ const hideLegendsInferred = (layout === null || layout === void 0 ? void 0 : layout.showlegend) === false || (layout === null || layout === void 0 ? void 0 : layout.showlegend) !== true && legends.length < 2;
1232
1314
  return {
1233
1315
  legends,
1234
- hideLegend: (layout === null || layout === void 0 ? void 0 : layout.showlegend) === false ? true : hideLegends
1316
+ hideLegend: isMultiPlot || hideLegendsInferred || hideLegendsData
1235
1317
  };
1236
1318
  };
1237
1319
  export const getNumberAtIndexOrDefault = (data, index)=>{
@@ -1269,3 +1351,215 @@ export const getValidXYRanges = (series)=>{
1269
1351
  }
1270
1352
  return ranges;
1271
1353
  };
1354
+ const getIndexFromKey = (key, pattern)=>{
1355
+ const normalizedKey = key.replace(pattern, '') === '' ? '1' : key.replace(pattern, '');
1356
+ return parseInt(normalizedKey, 10) - 1;
1357
+ };
1358
+ export const getGridProperties = (layout, isMultiPlot)=>{
1359
+ var _layout_annotations;
1360
+ const gridX = [];
1361
+ const gridY = [];
1362
+ const annotations = {};
1363
+ let templateRows = '1fr';
1364
+ let templateColumns = '1fr';
1365
+ const gridLayout = {};
1366
+ if (layout === undefined || layout === null || Object.keys(layout).length === 0) {
1367
+ return {
1368
+ templateRows,
1369
+ templateColumns,
1370
+ layout: gridLayout
1371
+ };
1372
+ }
1373
+ if (!layout.xaxis || !layout.yaxis) {
1374
+ return {
1375
+ templateRows,
1376
+ templateColumns,
1377
+ layout: gridLayout
1378
+ };
1379
+ }
1380
+ if (!isMultiPlot) {
1381
+ return {
1382
+ templateRows,
1383
+ templateColumns,
1384
+ layout: gridLayout
1385
+ };
1386
+ }
1387
+ Object.keys(layout).forEach((key)=>{
1388
+ if (key.startsWith('xaxis')) {
1389
+ var _layout_key, _layout_key1;
1390
+ const index = getIndexFromKey(key, 'xaxis');
1391
+ var _layout_key_anchor;
1392
+ const anchor = (_layout_key_anchor = (_layout_key = layout[key]) === null || _layout_key === void 0 ? void 0 : _layout_key.anchor) !== null && _layout_key_anchor !== void 0 ? _layout_key_anchor : 'y';
1393
+ const anchorIndex = getIndexFromKey(anchor, 'y');
1394
+ if (index !== anchorIndex) {
1395
+ throw new Error(`Invalid layout: xaxis ${index + 1} anchor should be y${anchorIndex + 1}`);
1396
+ }
1397
+ var _layout_key_domain;
1398
+ gridX[index] = (_layout_key_domain = (_layout_key1 = layout[key]) === null || _layout_key1 === void 0 ? void 0 : _layout_key1.domain) !== null && _layout_key_domain !== void 0 ? _layout_key_domain : [];
1399
+ } else if (key.startsWith('yaxis')) {
1400
+ var _layout_key2, _layout_key3;
1401
+ const index = getIndexFromKey(key, 'yaxis');
1402
+ var _layout_key_anchor1;
1403
+ const anchor = (_layout_key_anchor1 = (_layout_key2 = layout[key]) === null || _layout_key2 === void 0 ? void 0 : _layout_key2.anchor) !== null && _layout_key_anchor1 !== void 0 ? _layout_key_anchor1 : 'x';
1404
+ const anchorIndex = getIndexFromKey(anchor, 'x');
1405
+ if (index !== anchorIndex) {
1406
+ var _layout_yaxis2;
1407
+ if (index === 1 && anchorIndex === 0 || ((_layout_yaxis2 = layout.yaxis2) === null || _layout_yaxis2 === void 0 ? void 0 : _layout_yaxis2.side) === 'right') {
1408
+ // Special case for secondary y axis where yaxis2 can anchor to x1
1409
+ return {
1410
+ templateRows,
1411
+ templateColumns
1412
+ };
1413
+ }
1414
+ throw new Error(`Invalid layout: yaxis ${index + 1} anchor should be x${anchorIndex + 1}`);
1415
+ }
1416
+ var _layout_key_domain1;
1417
+ gridY[index] = (_layout_key_domain1 = (_layout_key3 = layout[key]) === null || _layout_key3 === void 0 ? void 0 : _layout_key3.domain) !== null && _layout_key_domain1 !== void 0 ? _layout_key_domain1 : [];
1418
+ }
1419
+ });
1420
+ (_layout_annotations = layout.annotations) === null || _layout_annotations === void 0 ? void 0 : _layout_annotations.forEach((annotation)=>{
1421
+ const xMatches = gridX.flatMap((interval, idx)=>(annotation === null || annotation === void 0 ? void 0 : annotation.x) >= interval[0] && (annotation === null || annotation === void 0 ? void 0 : annotation.x) <= interval[1] ? [
1422
+ idx
1423
+ ] : []);
1424
+ const yMatch = gridY.findIndex((interval, yIndex)=>xMatches.includes(yIndex) && (annotation === null || annotation === void 0 ? void 0 : annotation.y) >= interval[0] && (annotation === null || annotation === void 0 ? void 0 : annotation.y) <= interval[1]);
1425
+ if (yMatch !== -1) {
1426
+ if (annotations[yMatch] === undefined) {
1427
+ annotations[yMatch] = {};
1428
+ }
1429
+ if ((annotation === null || annotation === void 0 ? void 0 : annotation.textangle) === 90) {
1430
+ annotations[yMatch].yAnnotation = annotation.text;
1431
+ } else {
1432
+ annotations[yMatch].xAnnotation = annotation.text;
1433
+ }
1434
+ }
1435
+ });
1436
+ if (gridX.length > 0) {
1437
+ const uniqueXIntervals = new Map();
1438
+ gridX.forEach((interval)=>{
1439
+ const key = `${interval[0]}-${interval[1]}`;
1440
+ if (!uniqueXIntervals.has(key)) {
1441
+ uniqueXIntervals.set(key, interval);
1442
+ }
1443
+ });
1444
+ const minXInterval = Math.min(...Array.from(uniqueXIntervals.values()).map((interval)=>interval[1] - interval[0]));
1445
+ templateColumns = Array.from(uniqueXIntervals.values()).map((interval)=>`${(interval[1] - interval[0]) / minXInterval}fr`).join(' ');
1446
+ let columnNumber = 1;
1447
+ let lastIntervalEnd = 0;
1448
+ gridX.forEach((interval, index)=>{
1449
+ if (interval.length === 0) {
1450
+ return;
1451
+ }
1452
+ const cellName = `x${index === 0 ? '' : index + 1}`;
1453
+ const annotationProps = annotations[index];
1454
+ const xAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.xAnnotation;
1455
+ if (interval[0] < lastIntervalEnd) {
1456
+ columnNumber = 1;
1457
+ }
1458
+ lastIntervalEnd = interval[1];
1459
+ const row = {
1460
+ row: -1,
1461
+ column: columnNumber,
1462
+ xAnnotation
1463
+ };
1464
+ gridLayout[cellName] = row;
1465
+ columnNumber += 1;
1466
+ });
1467
+ }
1468
+ const numColumns = Math.max(...Object.values(gridLayout).map((cell)=>{
1469
+ var _cell_column;
1470
+ return (_cell_column = cell.column) !== null && _cell_column !== void 0 ? _cell_column : 0;
1471
+ }));
1472
+ const columnFill = {};
1473
+ for(let i = 1; i <= numColumns; i++){
1474
+ columnFill[i] = {
1475
+ row: 1,
1476
+ fillDomain: 0
1477
+ };
1478
+ }
1479
+ if (gridY.length > 0) {
1480
+ const uniqueYIntervals = new Map();
1481
+ gridY.forEach((interval)=>{
1482
+ const key = `${interval[0]}-${interval[1]}`;
1483
+ if (!uniqueYIntervals.has(key)) {
1484
+ uniqueYIntervals.set(key, interval);
1485
+ }
1486
+ });
1487
+ const minYInterval = Math.min(...Array.from(uniqueYIntervals.values()).map((interval)=>interval[1] - interval[0]));
1488
+ templateRows = Array.from(uniqueYIntervals.values()).map((interval)=>`${(interval[1] - interval[0]) / minYInterval}fr`).join(' ');
1489
+ gridY.forEach((interval, index)=>{
1490
+ if (interval.length === 0) {
1491
+ return;
1492
+ }
1493
+ const cellName = `x${index === 0 ? '' : index + 1}`;
1494
+ const annotationProps = annotations[index];
1495
+ const yAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.yAnnotation;
1496
+ const cell = gridLayout[cellName];
1497
+ if (cell !== undefined) {
1498
+ cell.row = columnFill[cell.column].row;
1499
+ cell.yAnnotation = yAnnotation;
1500
+ }
1501
+ columnFill[cell.column].fillDomain = interval[1];
1502
+ columnFill[cell.column].row += 1;
1503
+ });
1504
+ }
1505
+ // reverse the order of rows in grid layout from bottom-top to top-bottom as required by CSS grid
1506
+ const reversedGridLayout = {};
1507
+ // find the maximum row number
1508
+ const maxRowNumber = Math.max(...Object.values(gridLayout).map((cell)=>{
1509
+ var _cell_row;
1510
+ return (_cell_row = cell.row) !== null && _cell_row !== void 0 ? _cell_row : 0;
1511
+ }));
1512
+ // iterate over the gridLayout and reverse the row numbers
1513
+ Object.keys(gridLayout).forEach((key)=>{
1514
+ const cell = gridLayout[key];
1515
+ if (cell.row !== undefined) {
1516
+ // reverse the row number
1517
+ cell.row = maxRowNumber - cell.row + 1;
1518
+ }
1519
+ reversedGridLayout[key] = cell;
1520
+ });
1521
+ return {
1522
+ templateRows,
1523
+ templateColumns,
1524
+ layout: reversedGridLayout
1525
+ };
1526
+ };
1527
+ /**
1528
+ * @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/category_order_defaults.js#L50}
1529
+ */ const getAxisCategoryOrderProps = (data, layout)=>{
1530
+ const result = {};
1531
+ const axesById = {
1532
+ x: layout === null || layout === void 0 ? void 0 : layout.xaxis,
1533
+ y: layout === null || layout === void 0 ? void 0 : layout.yaxis
1534
+ };
1535
+ Object.keys(axesById).forEach((axId)=>{
1536
+ const ax = axesById[axId];
1537
+ const axLetter = axId[0];
1538
+ const propName = `${axLetter}AxisCategoryOrder`;
1539
+ const values = [];
1540
+ data.forEach((series)=>{
1541
+ var _series_axLetter;
1542
+ (_series_axLetter = series[axLetter]) === null || _series_axLetter === void 0 ? void 0 : _series_axLetter.forEach((val)=>{
1543
+ if (!isInvalidValue(val)) {
1544
+ values.push(val);
1545
+ }
1546
+ });
1547
+ });
1548
+ const isAxisTypeCategory = (ax === null || ax === void 0 ? void 0 : ax.type) === 'category' || isStringArray(values) && !isNumberArray(values) && !isDateArray(values);
1549
+ if (!isAxisTypeCategory) {
1550
+ return;
1551
+ }
1552
+ const isValidArray = isArrayOrTypedArray(ax === null || ax === void 0 ? void 0 : ax.categoryarray) && ax.categoryarray.length > 0;
1553
+ if (isValidArray && (!(ax === null || ax === void 0 ? void 0 : ax.categoryorder) || ax.categoryorder === 'array')) {
1554
+ result[propName] = ax.categoryarray;
1555
+ return;
1556
+ }
1557
+ if (!(ax === null || ax === void 0 ? void 0 : ax.categoryorder) || ax.categoryorder === 'trace' || ax.categoryorder === 'array') {
1558
+ const categoriesInTraceOrder = Array.from(new Set(values));
1559
+ result[propName] = categoriesInTraceOrder;
1560
+ return;
1561
+ }
1562
+ result[propName] = ax.categoryorder;
1563
+ });
1564
+ return result;
1565
+ };