@fluentui/react-charts 0.0.0-nightly-20250822-0407.1 → 0.0.0-nightly-20250826-0412.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 (112) hide show
  1. package/CHANGELOG.md +15 -15
  2. package/dist/index.d.ts +11 -1
  3. package/lib/components/AreaChart/useAreaChartStyles.styles.js +2 -2
  4. package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
  5. package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js +3 -15
  6. package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
  7. package/lib/components/CommonComponents/CartesianChart.js +24 -27
  8. package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
  9. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +17 -14
  10. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  11. package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +6 -33
  12. package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
  13. package/lib/components/DeclarativeChart/DeclarativeChart.js +32 -16
  14. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  15. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +149 -134
  16. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  17. package/lib/components/DonutChart/DonutChart.js +6 -1
  18. package/lib/components/DonutChart/DonutChart.js.map +1 -1
  19. package/lib/components/DonutChart/DonutChart.types.js.map +1 -1
  20. package/lib/components/DonutChart/useDonutChartStyles.styles.js +21 -4
  21. package/lib/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
  22. package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js +8 -4
  23. package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
  24. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +4 -17
  25. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  26. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +4 -21
  27. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
  28. package/lib/components/LineChart/LineChart.js +111 -81
  29. package/lib/components/LineChart/LineChart.js.map +1 -1
  30. package/lib/components/LineChart/LineChart.types.js.map +1 -1
  31. package/lib/components/LineChart/useLineChartStyles.styles.js +23 -10
  32. package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  33. package/lib/components/LineChart/useLineChartStyles.styles.raw.js +4 -21
  34. package/lib/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
  35. package/lib/components/SankeyChart/useSankeyChartStyles.styles.js +12 -25
  36. package/lib/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
  37. package/lib/components/SankeyChart/useSankeyChartStyles.styles.raw.js +2 -12
  38. package/lib/components/SankeyChart/useSankeyChartStyles.styles.raw.js.map +1 -1
  39. package/lib/components/ScatterChart/useScatterChartStyles.styles.js +11 -7
  40. package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  41. package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js +4 -22
  42. package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
  43. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +8 -6
  44. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  45. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +5 -19
  46. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
  47. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +7 -6
  48. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
  49. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +4 -19
  50. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
  51. package/lib/utilities/Common.styles.js +47 -0
  52. package/lib/utilities/Common.styles.js.map +1 -0
  53. package/lib/utilities/Common.styles.raw.js +47 -0
  54. package/lib/utilities/Common.styles.raw.js.map +1 -0
  55. package/lib/utilities/SVGTooltipText.js.map +1 -1
  56. package/lib/utilities/index.js +1 -0
  57. package/lib/utilities/index.js.map +1 -1
  58. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
  59. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js +2 -14
  60. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
  61. package/lib-commonjs/components/CommonComponents/CartesianChart.js +24 -27
  62. package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
  63. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +15 -13
  64. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  65. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +4 -32
  66. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
  67. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +31 -15
  68. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  69. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +158 -134
  70. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  71. package/lib-commonjs/components/DonutChart/DonutChart.js +6 -1
  72. package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
  73. package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -1
  74. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js +32 -4
  75. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
  76. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js +8 -4
  77. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
  78. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +2 -19
  79. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  80. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +3 -20
  81. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
  82. package/lib-commonjs/components/LineChart/LineChart.js +111 -81
  83. package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
  84. package/lib-commonjs/components/LineChart/LineChart.types.js.map +1 -1
  85. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js +30 -9
  86. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  87. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js +2 -20
  88. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
  89. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js +23 -33
  90. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
  91. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.raw.js +1 -12
  92. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.raw.js.map +1 -1
  93. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js +13 -7
  94. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  95. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js +2 -20
  96. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
  97. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +5 -3
  98. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  99. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +3 -17
  100. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
  101. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +5 -3
  102. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
  103. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +3 -18
  104. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
  105. package/lib-commonjs/utilities/Common.styles.js +71 -0
  106. package/lib-commonjs/utilities/Common.styles.js.map +1 -0
  107. package/lib-commonjs/utilities/Common.styles.raw.js +71 -0
  108. package/lib-commonjs/utilities/Common.styles.raw.js.map +1 -0
  109. package/lib-commonjs/utilities/SVGTooltipText.js.map +1 -1
  110. package/lib-commonjs/utilities/index.js +1 -0
  111. package/lib-commonjs/utilities/index.js.map +1 -1
  112. package/package.json +12 -12
@@ -8,6 +8,8 @@ import { isArrayOrTypedArray, isDate, isDateArray, isNumberArray, isStringArray,
8
8
  import { curveCardinal as d3CurveCardinal } from 'd3-shape';
9
9
  import { getOpacity, extractColor, resolveColor } 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',
@@ -241,7 +243,7 @@ export const transformPlotlyJsonToDonutProps = (input, isMultiPlot, colorMap, co
241
243
  chartTitle,
242
244
  chartData: Object.values(mapLegendToDataPoint)
243
245
  },
244
- 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,
245
247
  width: (_input_layout6 = input.layout) === null || _input_layout6 === void 0 ? void 0 : _input_layout6.width,
246
248
  height,
247
249
  innerRadius,
@@ -562,6 +564,7 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
562
564
  const seriesColor = resolveColor(extractedColors, index, legend, colorMap, isDarkTheme);
563
565
  const seriesOpacity = getOpacity(series, index);
564
566
  mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
567
+ // if mode contains 'text', we prioritize showing the text over curving the line
565
568
  const lineOptions = !((_series_mode1 = series.mode) === null || _series_mode1 === void 0 ? void 0 : _series_mode1.includes('text')) ? getLineOptions(series.line) : undefined;
566
569
  const legendShape = getLegendShape(series);
567
570
  const validXYRanges = getValidXYRanges(series);
@@ -1305,25 +1308,44 @@ const getLegendShape = (series)=>{
1305
1308
  }
1306
1309
  return 'default';
1307
1310
  };
1308
- export const getAllupLegendsProps = (input, colorMap, colorwayType, isDarkTheme)=>{
1311
+ export const getAllupLegendsProps = (input, colorMap, colorwayType, traceInfo, isDarkTheme)=>{
1309
1312
  const allupLegends = [];
1310
1313
  // reduce on showlegend boolean propperty. reduce should return true if at least one series has showlegend true
1311
1314
  const toShowLegend = input.data.reduce((acc, series)=>{
1312
- return acc || series.showlegend === true;
1315
+ return acc || series.showlegend === true || series.showlegend === undefined;
1313
1316
  }, false);
1314
1317
  if (toShowLegend) {
1315
1318
  input.data.forEach((series, index)=>{
1316
- var _series_line, _series_marker, _input_layout_template_layout, _input_layout_template, _input_layout;
1317
- const name = series.legendgroup;
1318
- 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);
1319
- const legendShape = getLegendShape(series);
1320
- 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);
1321
- if (name !== undefined && allupLegends.some((group)=>group.title === name) === false) {
1322
- allupLegends.push({
1323
- title: name,
1324
- color: resolvedColor,
1325
- shape: legendShape
1319
+ if (traceInfo[index].type === 'donut') {
1320
+ var _input_layout, _input_layout_template_layout, _input_layout_template, _input_layout1, _input_layout2, _pieSeries_marker, _pieSeries_labels;
1321
+ const pieSeries = series;
1322
+ var _input_layout_piecolorway, _input_layout_piecolorway1;
1323
+ 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);
1324
+ (_pieSeries_labels = pieSeries.labels) === null || _pieSeries_labels === void 0 ? void 0 : _pieSeries_labels.forEach((label, labelIndex)=>{
1325
+ const legend = `${label}`;
1326
+ // resolve color for each legend from the extracted colors
1327
+ const color = resolveColor(colors, labelIndex, legend, colorMap, isDarkTheme);
1328
+ if (legend !== '' && allupLegends.some((group)=>group.title === legend) === false) {
1329
+ allupLegends.push({
1330
+ title: legend,
1331
+ color
1332
+ });
1333
+ }
1326
1334
  });
1335
+ } else if (isNonPlotType(traceInfo[index].type) === false) {
1336
+ var _plotSeries_line, _plotSeries_marker, _input_layout_template_layout1, _input_layout_template1, _input_layout3;
1337
+ const plotSeries = series;
1338
+ const name = plotSeries.legendgroup;
1339
+ 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);
1340
+ const legendShape = getLegendShape(plotSeries);
1341
+ 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);
1342
+ if (name !== undefined && name !== '' && allupLegends.some((group)=>group.title === name) === false) {
1343
+ allupLegends.push({
1344
+ title: name,
1345
+ color: resolvedColor,
1346
+ shape: legendShape
1347
+ });
1348
+ }
1327
1349
  }
1328
1350
  });
1329
1351
  }
@@ -1389,28 +1411,21 @@ const getIndexFromKey = (key, pattern)=>{
1389
1411
  const normalizedKey = key.replace(pattern, '') === '' ? '1' : key.replace(pattern, '');
1390
1412
  return parseInt(normalizedKey, 10) - 1;
1391
1413
  };
1392
- export const getGridProperties = (layout, isMultiPlot)=>{
1393
- var _layout_annotations;
1394
- const gridX = [];
1395
- const gridY = [];
1414
+ export const isNonPlotType = (chartType)=>{
1415
+ return [
1416
+ 'donut',
1417
+ 'sankey',
1418
+ 'pie'
1419
+ ].includes(chartType);
1420
+ };
1421
+ export const getGridProperties = (schema, isMultiPlot, validTracesInfo)=>{
1422
+ const domainX = [];
1423
+ const domainY = [];
1424
+ let cartesianDomains = 0;
1396
1425
  const annotations = {};
1397
1426
  let templateRows = '1fr';
1398
1427
  let templateColumns = '1fr';
1399
1428
  const gridLayout = {};
1400
- if (layout === undefined || layout === null || Object.keys(layout).length === 0) {
1401
- return {
1402
- templateRows,
1403
- templateColumns,
1404
- layout: gridLayout
1405
- };
1406
- }
1407
- if (!layout.xaxis || !layout.yaxis) {
1408
- return {
1409
- templateRows,
1410
- templateColumns,
1411
- layout: gridLayout
1412
- };
1413
- }
1414
1429
  if (!isMultiPlot) {
1415
1430
  return {
1416
1431
  templateRows,
@@ -1418,144 +1433,144 @@ export const getGridProperties = (layout, isMultiPlot)=>{
1418
1433
  layout: gridLayout
1419
1434
  };
1420
1435
  }
1421
- Object.keys(layout).forEach((key)=>{
1422
- if (key.startsWith('xaxis')) {
1423
- var _layout_key, _layout_key1;
1424
- const index = getIndexFromKey(key, 'xaxis');
1425
- var _layout_key_anchor;
1426
- 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';
1427
- const anchorIndex = getIndexFromKey(anchor, 'y');
1428
- if (index !== anchorIndex) {
1429
- throw new Error(`Invalid layout: xaxis ${index + 1} anchor should be y${anchorIndex + 1}`);
1430
- }
1431
- var _layout_key_domain;
1432
- 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 : [];
1433
- } else if (key.startsWith('yaxis')) {
1434
- var _layout_key2, _layout_key3;
1435
- const index = getIndexFromKey(key, 'yaxis');
1436
- var _layout_key_anchor1;
1437
- 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';
1438
- const anchorIndex = getIndexFromKey(anchor, 'x');
1439
- if (index !== anchorIndex) {
1440
- var _layout_yaxis2;
1441
- if (index === 1 && anchorIndex === 0 || ((_layout_yaxis2 = layout.yaxis2) === null || _layout_yaxis2 === void 0 ? void 0 : _layout_yaxis2.side) === 'right') {
1442
- // Special case for secondary y axis where yaxis2 can anchor to x1
1443
- return {
1444
- templateRows,
1445
- templateColumns
1446
- };
1436
+ const layout = schema === null || schema === void 0 ? void 0 : schema.layout;
1437
+ if (layout !== undefined && layout !== null && Object.keys(layout).length > 0) {
1438
+ Object.keys(layout !== null && layout !== void 0 ? layout : {}).forEach((key)=>{
1439
+ if (key.startsWith('xaxis')) {
1440
+ var _layout_key;
1441
+ const index = getIndexFromKey(key, 'xaxis');
1442
+ var _layout_key_anchor;
1443
+ 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';
1444
+ const anchorIndex = getIndexFromKey(anchor, 'y');
1445
+ if (index !== anchorIndex) {
1446
+ throw new Error(`Invalid layout: xaxis ${index + 1} anchor should be y${anchorIndex + 1}`);
1447
+ }
1448
+ const xAxisLayout = layout[key];
1449
+ const domainXInfo = {
1450
+ start: (xAxisLayout === null || xAxisLayout === void 0 ? void 0 : xAxisLayout.domain) ? xAxisLayout.domain[0] : 0,
1451
+ end: (xAxisLayout === null || xAxisLayout === void 0 ? void 0 : xAxisLayout.domain) ? xAxisLayout.domain[1] : 1
1452
+ };
1453
+ domainX.push(domainXInfo);
1454
+ } else if (key.startsWith('yaxis')) {
1455
+ var _layout_key1;
1456
+ const index = getIndexFromKey(key, 'yaxis');
1457
+ var _layout_key_anchor1;
1458
+ 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';
1459
+ const anchorIndex = getIndexFromKey(anchor, 'x');
1460
+ if (index !== anchorIndex) {
1461
+ var _layout_yaxis2;
1462
+ if (index === 1 && anchorIndex === 0 || ((_layout_yaxis2 = layout.yaxis2) === null || _layout_yaxis2 === void 0 ? void 0 : _layout_yaxis2.side) === 'right') {
1463
+ // Special case for secondary y axis where yaxis2 can anchor to x1
1464
+ return {
1465
+ templateRows,
1466
+ templateColumns
1467
+ };
1468
+ }
1469
+ throw new Error(`Invalid layout: yaxis ${index + 1} anchor should be x${anchorIndex + 1}`);
1447
1470
  }
1448
- throw new Error(`Invalid layout: yaxis ${index + 1} anchor should be x${anchorIndex + 1}`);
1471
+ const yAxisLayout = layout[key];
1472
+ const domainYInfo = {
1473
+ start: (yAxisLayout === null || yAxisLayout === void 0 ? void 0 : yAxisLayout.domain) ? yAxisLayout.domain[0] : 0,
1474
+ end: (yAxisLayout === null || yAxisLayout === void 0 ? void 0 : yAxisLayout.domain) ? yAxisLayout.domain[1] : 1
1475
+ };
1476
+ domainY.push(domainYInfo);
1449
1477
  }
1450
- var _layout_key_domain1;
1451
- 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 : [];
1478
+ });
1479
+ }
1480
+ cartesianDomains = domainX.length; // Assuming that the number of x and y axes is the same
1481
+ validTracesInfo.forEach((trace, index)=>{
1482
+ if (isNonPlotType(trace.type)) {
1483
+ var _schema_data, _series_domain, _series_domain1, _series_domain2, _series_domain3;
1484
+ const series = schema === null || schema === void 0 ? void 0 : (_schema_data = schema.data) === null || _schema_data === void 0 ? void 0 : _schema_data[index];
1485
+ const domainXInfo = {
1486
+ start: ((_series_domain = series.domain) === null || _series_domain === void 0 ? void 0 : _series_domain.x) ? series.domain.x[0] : 0,
1487
+ end: ((_series_domain1 = series.domain) === null || _series_domain1 === void 0 ? void 0 : _series_domain1.x) ? series.domain.x[1] : 1
1488
+ };
1489
+ const domainYInfo = {
1490
+ start: ((_series_domain2 = series.domain) === null || _series_domain2 === void 0 ? void 0 : _series_domain2.y) ? series.domain.y[0] : 0,
1491
+ end: ((_series_domain3 = series.domain) === null || _series_domain3 === void 0 ? void 0 : _series_domain3.y) ? series.domain.y[1] : 1
1492
+ };
1493
+ domainX.push(domainXInfo);
1494
+ domainY.push(domainYInfo);
1452
1495
  }
1453
1496
  });
1454
- (_layout_annotations = layout.annotations) === null || _layout_annotations === void 0 ? void 0 : _layout_annotations.forEach((annotation)=>{
1455
- 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] ? [
1456
- idx
1457
- ] : []);
1458
- 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]);
1459
- if (yMatch !== -1) {
1460
- if (annotations[yMatch] === undefined) {
1461
- annotations[yMatch] = {};
1462
- }
1463
- if ((annotation === null || annotation === void 0 ? void 0 : annotation.textangle) === 90) {
1464
- annotations[yMatch].yAnnotation = annotation.text;
1465
- } else {
1466
- annotations[yMatch].xAnnotation = annotation.text;
1497
+ if (layout !== undefined && layout !== null && Object.keys(layout).length > 0) {
1498
+ var _layout_annotations;
1499
+ (_layout_annotations = layout.annotations) === null || _layout_annotations === void 0 ? void 0 : _layout_annotations.forEach((annotation)=>{
1500
+ 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 ? [
1501
+ idx
1502
+ ] : []);
1503
+ 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);
1504
+ if (yMatch !== -1) {
1505
+ if (annotations[yMatch] === undefined) {
1506
+ annotations[yMatch] = {};
1507
+ }
1508
+ if ((annotation === null || annotation === void 0 ? void 0 : annotation.textangle) === 90) {
1509
+ annotations[yMatch].yAnnotation = annotation.text;
1510
+ } else {
1511
+ annotations[yMatch].xAnnotation = annotation.text;
1512
+ }
1467
1513
  }
1468
- }
1469
- });
1470
- if (gridX.length > 0) {
1514
+ });
1515
+ }
1516
+ if (domainX.length > 0) {
1471
1517
  const uniqueXIntervals = new Map();
1472
- gridX.forEach((interval)=>{
1473
- const key = `${interval[0]}-${interval[1]}`;
1518
+ domainX.forEach((interval)=>{
1519
+ const key = `${interval.start}-${interval.end}`;
1474
1520
  if (!uniqueXIntervals.has(key)) {
1475
1521
  uniqueXIntervals.set(key, interval);
1476
1522
  }
1477
1523
  });
1478
- const minXInterval = Math.min(...Array.from(uniqueXIntervals.values()).map((interval)=>interval[1] - interval[0]));
1479
- templateColumns = Array.from(uniqueXIntervals.values()).map((interval)=>`${(interval[1] - interval[0]) / minXInterval}fr`).join(' ');
1480
- let columnNumber = 1;
1481
- let lastIntervalEnd = 0;
1482
- gridX.forEach((interval, index)=>{
1483
- if (interval.length === 0) {
1484
- return;
1485
- }
1486
- const cellName = `x${index === 0 ? '' : index + 1}`;
1524
+ const sortedXStart = Array.from(uniqueXIntervals.values()).map((interval)=>interval.start).sort();
1525
+ templateColumns = `repeat(${sortedXStart.length}, 1fr)`;
1526
+ domainX.forEach((interval, index)=>{
1527
+ const cellName = index >= cartesianDomains ? `${NON_PLOT_KEY_PREFIX}${index - cartesianDomains + 1}` : `x${index === 0 ? '' : index + 1}`;
1528
+ const columnIndex = sortedXStart.findIndex((start)=>start === interval.start);
1529
+ const columnNumber = columnIndex + 1; // Column numbers are 1-based
1487
1530
  const annotationProps = annotations[index];
1488
1531
  const xAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.xAnnotation;
1489
- if (interval[0] < lastIntervalEnd) {
1490
- columnNumber = 1;
1491
- }
1492
- lastIntervalEnd = interval[1];
1493
1532
  const row = {
1494
1533
  row: -1,
1495
1534
  column: columnNumber,
1496
- xAnnotation
1535
+ xAnnotation,
1536
+ xDomain: interval,
1537
+ yDomain: {
1538
+ start: 0,
1539
+ end: 1
1540
+ }
1497
1541
  };
1498
1542
  gridLayout[cellName] = row;
1499
- columnNumber += 1;
1500
1543
  });
1501
1544
  }
1502
- const numColumns = Math.max(...Object.values(gridLayout).map((cell)=>{
1503
- var _cell_column;
1504
- return (_cell_column = cell.column) !== null && _cell_column !== void 0 ? _cell_column : 0;
1505
- }));
1506
- const columnFill = {};
1507
- for(let i = 1; i <= numColumns; i++){
1508
- columnFill[i] = {
1509
- row: 1,
1510
- fillDomain: 0
1511
- };
1512
- }
1513
- if (gridY.length > 0) {
1545
+ if (domainY.length > 0) {
1514
1546
  const uniqueYIntervals = new Map();
1515
- gridY.forEach((interval)=>{
1516
- const key = `${interval[0]}-${interval[1]}`;
1547
+ domainY.forEach((interval)=>{
1548
+ const key = `${interval.start}-${interval.end}`;
1517
1549
  if (!uniqueYIntervals.has(key)) {
1518
1550
  uniqueYIntervals.set(key, interval);
1519
1551
  }
1520
1552
  });
1521
- const minYInterval = Math.min(...Array.from(uniqueYIntervals.values()).map((interval)=>interval[1] - interval[0]));
1522
- templateRows = Array.from(uniqueYIntervals.values()).map((interval)=>`${(interval[1] - interval[0]) / minYInterval}fr`).join(' ');
1523
- gridY.forEach((interval, index)=>{
1524
- if (interval.length === 0) {
1525
- return;
1526
- }
1527
- const cellName = `x${index === 0 ? '' : index + 1}`;
1553
+ const sortedYStart = Array.from(uniqueYIntervals.values()).map((interval)=>interval.start).sort();
1554
+ const numberOfRows = sortedYStart.length;
1555
+ templateRows = `repeat(${numberOfRows}, 1fr)`;
1556
+ domainY.forEach((interval, index)=>{
1557
+ const cellName = index >= cartesianDomains ? `${NON_PLOT_KEY_PREFIX}${index - cartesianDomains + 1}` : `x${index === 0 ? '' : index + 1}`;
1558
+ const rowIndex = sortedYStart.findIndex((start)=>start === interval.start);
1559
+ const rowNumber = numberOfRows - rowIndex; // Rows are 1-based and we need to reverse the order for CSS grid
1528
1560
  const annotationProps = annotations[index];
1529
1561
  const yAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.yAnnotation;
1530
1562
  const cell = gridLayout[cellName];
1531
1563
  if (cell !== undefined) {
1532
- cell.row = columnFill[cell.column].row;
1564
+ cell.row = rowNumber;
1533
1565
  cell.yAnnotation = yAnnotation;
1566
+ cell.yDomain = interval;
1534
1567
  }
1535
- columnFill[cell.column].fillDomain = interval[1];
1536
- columnFill[cell.column].row += 1;
1537
1568
  });
1538
1569
  }
1539
- // reverse the order of rows in grid layout from bottom-top to top-bottom as required by CSS grid
1540
- const reversedGridLayout = {};
1541
- // find the maximum row number
1542
- const maxRowNumber = Math.max(...Object.values(gridLayout).map((cell)=>{
1543
- var _cell_row;
1544
- return (_cell_row = cell.row) !== null && _cell_row !== void 0 ? _cell_row : 0;
1545
- }));
1546
- // iterate over the gridLayout and reverse the row numbers
1547
- Object.keys(gridLayout).forEach((key)=>{
1548
- const cell = gridLayout[key];
1549
- if (cell.row !== undefined) {
1550
- // reverse the row number
1551
- cell.row = maxRowNumber - cell.row + 1;
1552
- }
1553
- reversedGridLayout[key] = cell;
1554
- });
1555
1570
  return {
1556
1571
  templateRows,
1557
1572
  templateColumns,
1558
- layout: reversedGridLayout
1573
+ layout: gridLayout
1559
1574
  };
1560
1575
  };
1561
1576
  /**