@fluentui/react-charts 0.0.0-nightly-20250822-0407.1 → 0.0.0-nightly-20250825-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 (29) hide show
  1. package/CHANGELOG.md +15 -15
  2. package/dist/index.d.ts +5 -1
  3. package/lib/components/CommonComponents/CartesianChart.js +8 -7
  4. package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
  5. package/lib/components/DeclarativeChart/DeclarativeChart.js +32 -16
  6. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  7. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +148 -134
  8. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  9. package/lib/components/DonutChart/DonutChart.js +6 -1
  10. package/lib/components/DonutChart/DonutChart.js.map +1 -1
  11. package/lib/components/DonutChart/DonutChart.types.js.map +1 -1
  12. package/lib/components/DonutChart/useDonutChartStyles.styles.js +21 -4
  13. package/lib/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
  14. package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js +16 -3
  15. package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
  16. package/lib-commonjs/components/CommonComponents/CartesianChart.js +8 -7
  17. package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
  18. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +31 -15
  19. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  20. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +157 -134
  21. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  22. package/lib-commonjs/components/DonutChart/DonutChart.js +6 -1
  23. package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
  24. package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -1
  25. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js +32 -4
  26. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
  27. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js +16 -3
  28. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
  29. package/package.json +12 -12
@@ -9,6 +9,12 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
+ NON_PLOT_KEY_PREFIX: function() {
13
+ return NON_PLOT_KEY_PREFIX;
14
+ },
15
+ SINGLE_REPEAT: function() {
16
+ return SINGLE_REPEAT;
17
+ },
12
18
  _getGaugeAxisColor: function() {
13
19
  return _getGaugeAxisColor;
14
20
  },
@@ -30,6 +36,9 @@ _export(exports, {
30
36
  getValidXYRanges: function() {
31
37
  return getValidXYRanges;
32
38
  },
39
+ isNonPlotType: function() {
40
+ return isNonPlotType;
41
+ },
33
42
  projectPolarToCartesian: function() {
34
43
  return projectPolarToCartesian;
35
44
  },
@@ -84,6 +93,8 @@ const _chartutilities = require("@fluentui/chart-utilities");
84
93
  const _d3shape = require("d3-shape");
85
94
  const _PlotlyColorAdapter = require("./PlotlyColorAdapter");
86
95
  const _d3color = require("d3-color");
96
+ const NON_PLOT_KEY_PREFIX = 'nonplot_';
97
+ const SINGLE_REPEAT = 'repeat(1, 1fr)';
87
98
  const dashOptions = {
88
99
  dot: {
89
100
  strokeDasharray: '1, 5',
@@ -316,7 +327,7 @@ const transformPlotlyJsonToDonutProps = (input, isMultiPlot, colorMap, colorwayT
316
327
  chartTitle,
317
328
  chartData: Object.values(mapLegendToDataPoint)
318
329
  },
319
- hideLegend: ((_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : _input_layout5.showlegend) === false ? true : false,
330
+ hideLegend: isMultiPlot || ((_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : _input_layout5.showlegend) === false,
320
331
  width: (_input_layout6 = input.layout) === null || _input_layout6 === void 0 ? void 0 : _input_layout6.width,
321
332
  height,
322
333
  innerRadius,
@@ -1374,25 +1385,44 @@ const getLegendShape = (series)=>{
1374
1385
  }
1375
1386
  return 'default';
1376
1387
  };
1377
- const getAllupLegendsProps = (input, colorMap, colorwayType, isDarkTheme)=>{
1388
+ const getAllupLegendsProps = (input, colorMap, colorwayType, traceInfo, isDarkTheme)=>{
1378
1389
  const allupLegends = [];
1379
1390
  // reduce on showlegend boolean propperty. reduce should return true if at least one series has showlegend true
1380
1391
  const toShowLegend = input.data.reduce((acc, series)=>{
1381
- return acc || series.showlegend === true;
1392
+ return acc || series.showlegend === true || series.showlegend === undefined;
1382
1393
  }, false);
1383
1394
  if (toShowLegend) {
1384
1395
  input.data.forEach((series, index)=>{
1385
- var _series_line, _series_marker, _input_layout_template_layout, _input_layout_template, _input_layout;
1386
- const name = series.legendgroup;
1387
- 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);
1388
- const legendShape = getLegendShape(series);
1389
- const resolvedColor = (0, _PlotlyColorAdapter.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);
1390
- if (name !== undefined && allupLegends.some((group)=>group.title === name) === false) {
1391
- allupLegends.push({
1392
- title: name,
1393
- color: resolvedColor,
1394
- shape: legendShape
1396
+ if (traceInfo[index].type === 'donut') {
1397
+ var _input_layout, _input_layout_template_layout, _input_layout_template, _input_layout1, _input_layout2, _pieSeries_marker, _pieSeries_labels;
1398
+ const pieSeries = series;
1399
+ var _input_layout_piecolorway, _input_layout_piecolorway1;
1400
+ const colors = (0, _PlotlyColorAdapter.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);
1401
+ (_pieSeries_labels = pieSeries.labels) === null || _pieSeries_labels === void 0 ? void 0 : _pieSeries_labels.forEach((label, labelIndex)=>{
1402
+ const legend = `${label}`;
1403
+ // resolve color for each legend from the extracted colors
1404
+ const color = (0, _PlotlyColorAdapter.resolveColor)(colors, labelIndex, legend, colorMap, isDarkTheme);
1405
+ if (legend !== '' && allupLegends.some((group)=>group.title === legend) === false) {
1406
+ allupLegends.push({
1407
+ title: legend,
1408
+ color
1409
+ });
1410
+ }
1395
1411
  });
1412
+ } else if (isNonPlotType(traceInfo[index].type) === false) {
1413
+ var _plotSeries_line, _plotSeries_marker, _input_layout_template_layout1, _input_layout_template1, _input_layout3;
1414
+ const plotSeries = series;
1415
+ const name = plotSeries.legendgroup;
1416
+ 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);
1417
+ const legendShape = getLegendShape(plotSeries);
1418
+ const resolvedColor = (0, _PlotlyColorAdapter.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);
1419
+ if (name !== undefined && name !== '' && allupLegends.some((group)=>group.title === name) === false) {
1420
+ allupLegends.push({
1421
+ title: name,
1422
+ color: resolvedColor,
1423
+ shape: legendShape
1424
+ });
1425
+ }
1396
1426
  }
1397
1427
  });
1398
1428
  }
@@ -1458,28 +1488,21 @@ const getIndexFromKey = (key, pattern)=>{
1458
1488
  const normalizedKey = key.replace(pattern, '') === '' ? '1' : key.replace(pattern, '');
1459
1489
  return parseInt(normalizedKey, 10) - 1;
1460
1490
  };
1461
- const getGridProperties = (layout, isMultiPlot)=>{
1462
- var _layout_annotations;
1463
- const gridX = [];
1464
- const gridY = [];
1491
+ const isNonPlotType = (chartType)=>{
1492
+ return [
1493
+ 'donut',
1494
+ 'sankey',
1495
+ 'pie'
1496
+ ].includes(chartType);
1497
+ };
1498
+ const getGridProperties = (schema, isMultiPlot, validTracesInfo)=>{
1499
+ const domainX = [];
1500
+ const domainY = [];
1501
+ let cartesianDomains = 0;
1465
1502
  const annotations = {};
1466
1503
  let templateRows = '1fr';
1467
1504
  let templateColumns = '1fr';
1468
1505
  const gridLayout = {};
1469
- if (layout === undefined || layout === null || Object.keys(layout).length === 0) {
1470
- return {
1471
- templateRows,
1472
- templateColumns,
1473
- layout: gridLayout
1474
- };
1475
- }
1476
- if (!layout.xaxis || !layout.yaxis) {
1477
- return {
1478
- templateRows,
1479
- templateColumns,
1480
- layout: gridLayout
1481
- };
1482
- }
1483
1506
  if (!isMultiPlot) {
1484
1507
  return {
1485
1508
  templateRows,
@@ -1487,144 +1510,144 @@ const getGridProperties = (layout, isMultiPlot)=>{
1487
1510
  layout: gridLayout
1488
1511
  };
1489
1512
  }
1490
- Object.keys(layout).forEach((key)=>{
1491
- if (key.startsWith('xaxis')) {
1492
- var _layout_key, _layout_key1;
1493
- const index = getIndexFromKey(key, 'xaxis');
1494
- var _layout_key_anchor;
1495
- 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';
1496
- const anchorIndex = getIndexFromKey(anchor, 'y');
1497
- if (index !== anchorIndex) {
1498
- throw new Error(`Invalid layout: xaxis ${index + 1} anchor should be y${anchorIndex + 1}`);
1499
- }
1500
- var _layout_key_domain;
1501
- 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 : [];
1502
- } else if (key.startsWith('yaxis')) {
1503
- var _layout_key2, _layout_key3;
1504
- const index = getIndexFromKey(key, 'yaxis');
1505
- var _layout_key_anchor1;
1506
- 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';
1507
- const anchorIndex = getIndexFromKey(anchor, 'x');
1508
- if (index !== anchorIndex) {
1509
- var _layout_yaxis2;
1510
- if (index === 1 && anchorIndex === 0 || ((_layout_yaxis2 = layout.yaxis2) === null || _layout_yaxis2 === void 0 ? void 0 : _layout_yaxis2.side) === 'right') {
1511
- // Special case for secondary y axis where yaxis2 can anchor to x1
1512
- return {
1513
- templateRows,
1514
- templateColumns
1515
- };
1513
+ const layout = schema === null || schema === void 0 ? void 0 : schema.layout;
1514
+ if (layout !== undefined && layout !== null && Object.keys(layout).length > 0) {
1515
+ Object.keys(layout !== null && layout !== void 0 ? layout : {}).forEach((key)=>{
1516
+ if (key.startsWith('xaxis')) {
1517
+ var _layout_key;
1518
+ const index = getIndexFromKey(key, 'xaxis');
1519
+ var _layout_key_anchor;
1520
+ 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';
1521
+ const anchorIndex = getIndexFromKey(anchor, 'y');
1522
+ if (index !== anchorIndex) {
1523
+ throw new Error(`Invalid layout: xaxis ${index + 1} anchor should be y${anchorIndex + 1}`);
1516
1524
  }
1517
- throw new Error(`Invalid layout: yaxis ${index + 1} anchor should be x${anchorIndex + 1}`);
1525
+ const xAxisLayout = layout[key];
1526
+ const domainXInfo = {
1527
+ start: (xAxisLayout === null || xAxisLayout === void 0 ? void 0 : xAxisLayout.domain) ? xAxisLayout.domain[0] : 0,
1528
+ end: (xAxisLayout === null || xAxisLayout === void 0 ? void 0 : xAxisLayout.domain) ? xAxisLayout.domain[1] : 1
1529
+ };
1530
+ domainX.push(domainXInfo);
1531
+ } else if (key.startsWith('yaxis')) {
1532
+ var _layout_key1;
1533
+ const index = getIndexFromKey(key, 'yaxis');
1534
+ var _layout_key_anchor1;
1535
+ 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';
1536
+ const anchorIndex = getIndexFromKey(anchor, 'x');
1537
+ if (index !== anchorIndex) {
1538
+ var _layout_yaxis2;
1539
+ if (index === 1 && anchorIndex === 0 || ((_layout_yaxis2 = layout.yaxis2) === null || _layout_yaxis2 === void 0 ? void 0 : _layout_yaxis2.side) === 'right') {
1540
+ // Special case for secondary y axis where yaxis2 can anchor to x1
1541
+ return {
1542
+ templateRows,
1543
+ templateColumns
1544
+ };
1545
+ }
1546
+ throw new Error(`Invalid layout: yaxis ${index + 1} anchor should be x${anchorIndex + 1}`);
1547
+ }
1548
+ const yAxisLayout = layout[key];
1549
+ const domainYInfo = {
1550
+ start: (yAxisLayout === null || yAxisLayout === void 0 ? void 0 : yAxisLayout.domain) ? yAxisLayout.domain[0] : 0,
1551
+ end: (yAxisLayout === null || yAxisLayout === void 0 ? void 0 : yAxisLayout.domain) ? yAxisLayout.domain[1] : 1
1552
+ };
1553
+ domainY.push(domainYInfo);
1518
1554
  }
1519
- var _layout_key_domain1;
1520
- 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 : [];
1555
+ });
1556
+ }
1557
+ cartesianDomains = domainX.length; // Assuming that the number of x and y axes is the same
1558
+ validTracesInfo.forEach((trace, index)=>{
1559
+ if (isNonPlotType(trace.type)) {
1560
+ var _schema_data, _series_domain, _series_domain1, _series_domain2, _series_domain3;
1561
+ const series = schema === null || schema === void 0 ? void 0 : (_schema_data = schema.data) === null || _schema_data === void 0 ? void 0 : _schema_data[index];
1562
+ const domainXInfo = {
1563
+ start: ((_series_domain = series.domain) === null || _series_domain === void 0 ? void 0 : _series_domain.x) ? series.domain.x[0] : 0,
1564
+ end: ((_series_domain1 = series.domain) === null || _series_domain1 === void 0 ? void 0 : _series_domain1.x) ? series.domain.x[1] : 1
1565
+ };
1566
+ const domainYInfo = {
1567
+ start: ((_series_domain2 = series.domain) === null || _series_domain2 === void 0 ? void 0 : _series_domain2.y) ? series.domain.y[0] : 0,
1568
+ end: ((_series_domain3 = series.domain) === null || _series_domain3 === void 0 ? void 0 : _series_domain3.y) ? series.domain.y[1] : 1
1569
+ };
1570
+ domainX.push(domainXInfo);
1571
+ domainY.push(domainYInfo);
1521
1572
  }
1522
1573
  });
1523
- (_layout_annotations = layout.annotations) === null || _layout_annotations === void 0 ? void 0 : _layout_annotations.forEach((annotation)=>{
1524
- 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] ? [
1525
- idx
1526
- ] : []);
1527
- 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]);
1528
- if (yMatch !== -1) {
1529
- if (annotations[yMatch] === undefined) {
1530
- annotations[yMatch] = {};
1531
- }
1532
- if ((annotation === null || annotation === void 0 ? void 0 : annotation.textangle) === 90) {
1533
- annotations[yMatch].yAnnotation = annotation.text;
1534
- } else {
1535
- annotations[yMatch].xAnnotation = annotation.text;
1574
+ if (layout !== undefined && layout !== null && Object.keys(layout).length > 0) {
1575
+ var _layout_annotations;
1576
+ (_layout_annotations = layout.annotations) === null || _layout_annotations === void 0 ? void 0 : _layout_annotations.forEach((annotation)=>{
1577
+ 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 ? [
1578
+ idx
1579
+ ] : []);
1580
+ 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);
1581
+ if (yMatch !== -1) {
1582
+ if (annotations[yMatch] === undefined) {
1583
+ annotations[yMatch] = {};
1584
+ }
1585
+ if ((annotation === null || annotation === void 0 ? void 0 : annotation.textangle) === 90) {
1586
+ annotations[yMatch].yAnnotation = annotation.text;
1587
+ } else {
1588
+ annotations[yMatch].xAnnotation = annotation.text;
1589
+ }
1536
1590
  }
1537
- }
1538
- });
1539
- if (gridX.length > 0) {
1591
+ });
1592
+ }
1593
+ if (domainX.length > 0) {
1540
1594
  const uniqueXIntervals = new Map();
1541
- gridX.forEach((interval)=>{
1542
- const key = `${interval[0]}-${interval[1]}`;
1595
+ domainX.forEach((interval)=>{
1596
+ const key = `${interval.start}-${interval.end}`;
1543
1597
  if (!uniqueXIntervals.has(key)) {
1544
1598
  uniqueXIntervals.set(key, interval);
1545
1599
  }
1546
1600
  });
1547
- const minXInterval = Math.min(...Array.from(uniqueXIntervals.values()).map((interval)=>interval[1] - interval[0]));
1548
- templateColumns = Array.from(uniqueXIntervals.values()).map((interval)=>`${(interval[1] - interval[0]) / minXInterval}fr`).join(' ');
1549
- let columnNumber = 1;
1550
- let lastIntervalEnd = 0;
1551
- gridX.forEach((interval, index)=>{
1552
- if (interval.length === 0) {
1553
- return;
1554
- }
1555
- const cellName = `x${index === 0 ? '' : index + 1}`;
1601
+ const sortedXStart = Array.from(uniqueXIntervals.values()).map((interval)=>interval.start).sort();
1602
+ templateColumns = `repeat(${sortedXStart.length}, 1fr)`;
1603
+ domainX.forEach((interval, index)=>{
1604
+ const cellName = index >= cartesianDomains ? `${NON_PLOT_KEY_PREFIX}${index - cartesianDomains + 1}` : `x${index === 0 ? '' : index + 1}`;
1605
+ const columnIndex = sortedXStart.findIndex((start)=>start === interval.start);
1606
+ const columnNumber = columnIndex + 1; // Column numbers are 1-based
1556
1607
  const annotationProps = annotations[index];
1557
1608
  const xAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.xAnnotation;
1558
- if (interval[0] < lastIntervalEnd) {
1559
- columnNumber = 1;
1560
- }
1561
- lastIntervalEnd = interval[1];
1562
1609
  const row = {
1563
1610
  row: -1,
1564
1611
  column: columnNumber,
1565
- xAnnotation
1612
+ xAnnotation,
1613
+ xDomain: interval,
1614
+ yDomain: {
1615
+ start: 0,
1616
+ end: 1
1617
+ }
1566
1618
  };
1567
1619
  gridLayout[cellName] = row;
1568
- columnNumber += 1;
1569
1620
  });
1570
1621
  }
1571
- const numColumns = Math.max(...Object.values(gridLayout).map((cell)=>{
1572
- var _cell_column;
1573
- return (_cell_column = cell.column) !== null && _cell_column !== void 0 ? _cell_column : 0;
1574
- }));
1575
- const columnFill = {};
1576
- for(let i = 1; i <= numColumns; i++){
1577
- columnFill[i] = {
1578
- row: 1,
1579
- fillDomain: 0
1580
- };
1581
- }
1582
- if (gridY.length > 0) {
1622
+ if (domainY.length > 0) {
1583
1623
  const uniqueYIntervals = new Map();
1584
- gridY.forEach((interval)=>{
1585
- const key = `${interval[0]}-${interval[1]}`;
1624
+ domainY.forEach((interval)=>{
1625
+ const key = `${interval.start}-${interval.end}`;
1586
1626
  if (!uniqueYIntervals.has(key)) {
1587
1627
  uniqueYIntervals.set(key, interval);
1588
1628
  }
1589
1629
  });
1590
- const minYInterval = Math.min(...Array.from(uniqueYIntervals.values()).map((interval)=>interval[1] - interval[0]));
1591
- templateRows = Array.from(uniqueYIntervals.values()).map((interval)=>`${(interval[1] - interval[0]) / minYInterval}fr`).join(' ');
1592
- gridY.forEach((interval, index)=>{
1593
- if (interval.length === 0) {
1594
- return;
1595
- }
1596
- const cellName = `x${index === 0 ? '' : index + 1}`;
1630
+ const sortedYStart = Array.from(uniqueYIntervals.values()).map((interval)=>interval.start).sort();
1631
+ const numberOfRows = sortedYStart.length;
1632
+ templateRows = `repeat(${numberOfRows}, 1fr)`;
1633
+ domainY.forEach((interval, index)=>{
1634
+ const cellName = index >= cartesianDomains ? `${NON_PLOT_KEY_PREFIX}${index - cartesianDomains + 1}` : `x${index === 0 ? '' : index + 1}`;
1635
+ const rowIndex = sortedYStart.findIndex((start)=>start === interval.start);
1636
+ const rowNumber = numberOfRows - rowIndex; // Rows are 1-based and we need to reverse the order for CSS grid
1597
1637
  const annotationProps = annotations[index];
1598
1638
  const yAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.yAnnotation;
1599
1639
  const cell = gridLayout[cellName];
1600
1640
  if (cell !== undefined) {
1601
- cell.row = columnFill[cell.column].row;
1641
+ cell.row = rowNumber;
1602
1642
  cell.yAnnotation = yAnnotation;
1643
+ cell.yDomain = interval;
1603
1644
  }
1604
- columnFill[cell.column].fillDomain = interval[1];
1605
- columnFill[cell.column].row += 1;
1606
1645
  });
1607
1646
  }
1608
- // reverse the order of rows in grid layout from bottom-top to top-bottom as required by CSS grid
1609
- const reversedGridLayout = {};
1610
- // find the maximum row number
1611
- const maxRowNumber = Math.max(...Object.values(gridLayout).map((cell)=>{
1612
- var _cell_row;
1613
- return (_cell_row = cell.row) !== null && _cell_row !== void 0 ? _cell_row : 0;
1614
- }));
1615
- // iterate over the gridLayout and reverse the row numbers
1616
- Object.keys(gridLayout).forEach((key)=>{
1617
- const cell = gridLayout[key];
1618
- if (cell.row !== undefined) {
1619
- // reverse the row number
1620
- cell.row = maxRowNumber - cell.row + 1;
1621
- }
1622
- reversedGridLayout[key] = cell;
1623
- });
1624
1647
  return {
1625
1648
  templateRows,
1626
1649
  templateColumns,
1627
- layout: reversedGridLayout
1650
+ layout: gridLayout
1628
1651
  };
1629
1652
  };
1630
1653
  /**