@fluentui/react-charting 5.24.4 → 5.24.6

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 (141) hide show
  1. package/CHANGELOG.json +55 -1
  2. package/CHANGELOG.md +24 -2
  3. package/config/tests.js +0 -12
  4. package/dist/react-charting.d.ts +4 -0
  5. package/dist/react-charting.js +1 -1
  6. package/dist/react-charting.min.js +1 -1
  7. package/etc/react-charting.api.md +1 -0
  8. package/lib/components/AreaChart/AreaChart.styles.js +2 -2
  9. package/lib/components/AreaChart/AreaChart.styles.js.map +1 -1
  10. package/lib/components/CommonComponents/CartesianChart.base.js +28 -21
  11. package/lib/components/CommonComponents/CartesianChart.base.js.map +1 -1
  12. package/lib/components/CommonComponents/CartesianChart.styles.js +35 -58
  13. package/lib/components/CommonComponents/CartesianChart.styles.js.map +1 -1
  14. package/lib/components/DeclarativeChart/DeclarativeChart.js +38 -16
  15. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  16. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +13 -3
  17. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +215 -139
  18. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  19. package/lib/components/DonutChart/DonutChart.base.js +1 -0
  20. package/lib/components/DonutChart/DonutChart.base.js.map +1 -1
  21. package/lib/components/DonutChart/DonutChart.styles.js +2 -0
  22. package/lib/components/DonutChart/DonutChart.styles.js.map +1 -1
  23. package/lib/components/DonutChart/DonutChart.types.d.ts +4 -0
  24. package/lib/components/DonutChart/DonutChart.types.js.map +1 -1
  25. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +3 -1
  26. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
  27. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.styles.js +3 -14
  28. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.styles.js.map +1 -1
  29. package/lib/components/LineChart/LineChart.styles.js +3 -11
  30. package/lib/components/LineChart/LineChart.styles.js.map +1 -1
  31. package/lib/components/SankeyChart/SankeyChart.styles.js +2 -1
  32. package/lib/components/SankeyChart/SankeyChart.styles.js.map +1 -1
  33. package/lib/components/ScatterChart/ScatterChart.styles.js +3 -14
  34. package/lib/components/ScatterChart/ScatterChart.styles.js.map +1 -1
  35. package/lib/components/VerticalBarChart/VerticalBarChart.base.js +3 -1
  36. package/lib/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
  37. package/lib/components/VerticalBarChart/VerticalBarChart.styles.js +3 -14
  38. package/lib/components/VerticalBarChart/VerticalBarChart.styles.js.map +1 -1
  39. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +3 -1
  40. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
  41. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.styles.js +3 -14
  42. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.styles.js.map +1 -1
  43. package/lib/utilities/Common.styles.d.ts +6 -0
  44. package/lib/utilities/Common.styles.js +51 -0
  45. package/lib/utilities/Common.styles.js.map +1 -0
  46. package/lib/utilities/SVGTooltipText.d.ts +1 -1
  47. package/lib/utilities/SVGTooltipText.js +3 -3
  48. package/lib/utilities/SVGTooltipText.js.map +1 -1
  49. package/lib/utilities/index.d.ts +1 -0
  50. package/lib/utilities/index.js +1 -0
  51. package/lib/utilities/index.js.map +1 -1
  52. package/lib-amd/components/AreaChart/AreaChart.styles.js +2 -2
  53. package/lib-amd/components/AreaChart/AreaChart.styles.js.map +1 -1
  54. package/lib-amd/components/CommonComponents/CartesianChart.base.js +28 -21
  55. package/lib-amd/components/CommonComponents/CartesianChart.base.js.map +1 -1
  56. package/lib-amd/components/CommonComponents/CartesianChart.styles.js +33 -57
  57. package/lib-amd/components/CommonComponents/CartesianChart.styles.js.map +1 -1
  58. package/lib-amd/components/DeclarativeChart/DeclarativeChart.js +37 -15
  59. package/lib-amd/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  60. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +13 -3
  61. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +216 -139
  62. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  63. package/lib-amd/components/DonutChart/DonutChart.base.js +1 -0
  64. package/lib-amd/components/DonutChart/DonutChart.base.js.map +1 -1
  65. package/lib-amd/components/DonutChart/DonutChart.styles.js +2 -1
  66. package/lib-amd/components/DonutChart/DonutChart.styles.js.map +1 -1
  67. package/lib-amd/components/DonutChart/DonutChart.types.d.ts +4 -0
  68. package/lib-amd/components/DonutChart/DonutChart.types.js.map +1 -1
  69. package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +3 -1
  70. package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
  71. package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.styles.js +3 -13
  72. package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.styles.js.map +1 -1
  73. package/lib-amd/components/LineChart/LineChart.styles.js +3 -10
  74. package/lib-amd/components/LineChart/LineChart.styles.js.map +1 -1
  75. package/lib-amd/components/SankeyChart/SankeyChart.styles.js +2 -2
  76. package/lib-amd/components/SankeyChart/SankeyChart.styles.js.map +1 -1
  77. package/lib-amd/components/ScatterChart/ScatterChart.styles.js +3 -13
  78. package/lib-amd/components/ScatterChart/ScatterChart.styles.js.map +1 -1
  79. package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js +3 -1
  80. package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
  81. package/lib-amd/components/VerticalBarChart/VerticalBarChart.styles.js +3 -13
  82. package/lib-amd/components/VerticalBarChart/VerticalBarChart.styles.js.map +1 -1
  83. package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +3 -1
  84. package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
  85. package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.styles.js +3 -13
  86. package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.styles.js.map +1 -1
  87. package/lib-amd/utilities/Common.styles.d.ts +6 -0
  88. package/lib-amd/utilities/Common.styles.js +57 -0
  89. package/lib-amd/utilities/Common.styles.js.map +1 -0
  90. package/lib-amd/utilities/SVGTooltipText.d.ts +1 -1
  91. package/lib-amd/utilities/SVGTooltipText.js +3 -3
  92. package/lib-amd/utilities/SVGTooltipText.js.map +1 -1
  93. package/lib-amd/utilities/index.d.ts +1 -0
  94. package/lib-amd/utilities/index.js +2 -1
  95. package/lib-amd/utilities/index.js.map +1 -1
  96. package/lib-commonjs/components/AreaChart/AreaChart.styles.js +2 -2
  97. package/lib-commonjs/components/AreaChart/AreaChart.styles.js.map +1 -1
  98. package/lib-commonjs/components/CommonComponents/CartesianChart.base.js +28 -21
  99. package/lib-commonjs/components/CommonComponents/CartesianChart.base.js.map +1 -1
  100. package/lib-commonjs/components/CommonComponents/CartesianChart.styles.js +33 -56
  101. package/lib-commonjs/components/CommonComponents/CartesianChart.styles.js.map +1 -1
  102. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +37 -15
  103. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  104. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +13 -3
  105. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +216 -139
  106. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  107. package/lib-commonjs/components/DonutChart/DonutChart.base.js +1 -0
  108. package/lib-commonjs/components/DonutChart/DonutChart.base.js.map +1 -1
  109. package/lib-commonjs/components/DonutChart/DonutChart.styles.js +2 -0
  110. package/lib-commonjs/components/DonutChart/DonutChart.styles.js.map +1 -1
  111. package/lib-commonjs/components/DonutChart/DonutChart.types.d.ts +4 -0
  112. package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -1
  113. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +3 -1
  114. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
  115. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.styles.js +3 -14
  116. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.styles.js.map +1 -1
  117. package/lib-commonjs/components/LineChart/LineChart.styles.js +3 -11
  118. package/lib-commonjs/components/LineChart/LineChart.styles.js.map +1 -1
  119. package/lib-commonjs/components/SankeyChart/SankeyChart.styles.js +2 -1
  120. package/lib-commonjs/components/SankeyChart/SankeyChart.styles.js.map +1 -1
  121. package/lib-commonjs/components/ScatterChart/ScatterChart.styles.js +3 -14
  122. package/lib-commonjs/components/ScatterChart/ScatterChart.styles.js.map +1 -1
  123. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js +3 -1
  124. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
  125. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.styles.js +3 -14
  126. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.styles.js.map +1 -1
  127. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +3 -1
  128. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
  129. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.styles.js +3 -14
  130. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.styles.js.map +1 -1
  131. package/lib-commonjs/utilities/Common.styles.d.ts +6 -0
  132. package/lib-commonjs/utilities/Common.styles.js +58 -0
  133. package/lib-commonjs/utilities/Common.styles.js.map +1 -0
  134. package/lib-commonjs/utilities/SVGTooltipText.d.ts +1 -1
  135. package/lib-commonjs/utilities/SVGTooltipText.js +3 -3
  136. package/lib-commonjs/utilities/SVGTooltipText.js.map +1 -1
  137. package/lib-commonjs/utilities/index.d.ts +1 -0
  138. package/lib-commonjs/utilities/index.js +1 -0
  139. package/lib-commonjs/utilities/index.js.map +1 -1
  140. package/package.json +2 -2
  141. package/src/components/DonutChart/DonutChart.types.ts +5 -0
@@ -5,10 +5,12 @@ import { format as d3Format } from 'd3-format';
5
5
  import { DataVizPalette, getColorFromToken } from '../../utilities/colors';
6
6
  import { GaugeChartVariant } from '../GaugeChart/index';
7
7
  import { findNumericMinMaxOfY, formatScientificLimitWidth, MIN_DONUT_RADIUS } from '../../utilities/utilities';
8
- import { isArrayOrTypedArray, isDate, isDateArray, isNumberArray, isStringArray, isYearArray, isInvalidValue, } from '@fluentui/chart-utilities';
8
+ import { isArrayOrTypedArray, isDate, isDateArray, isNumberArray, isStringArray, isYearArray, isInvalidValue, formatToLocaleString, } from '@fluentui/chart-utilities';
9
9
  import { curveCardinal as d3CurveCardinal } from 'd3-shape';
10
10
  import { getOpacity, extractColor, resolveColor } from './PlotlyColorAdapter';
11
11
  import { rgb } from 'd3-color';
12
+ export var NON_PLOT_KEY_PREFIX = 'nonplot_';
13
+ export var SINGLE_REPEAT = 'repeat(1, 1fr)';
12
14
  var dashOptions = {
13
15
  dot: {
14
16
  strokeDasharray: '1, 5',
@@ -56,6 +58,47 @@ function getTitles(layout) {
56
58
  };
57
59
  return titles;
58
60
  }
61
+ var getXAxisTickFormat = function (series, layout) {
62
+ var xAxis = getXAxisProperties(series, layout);
63
+ if (xAxis === null || xAxis === void 0 ? void 0 : xAxis.tickformat) {
64
+ return {
65
+ tickFormat: xAxis === null || xAxis === void 0 ? void 0 : xAxis.tickformat,
66
+ };
67
+ }
68
+ return {};
69
+ };
70
+ var getYAxisTickFormat = function (series, layout) {
71
+ var yAxis = getYAxisProperties(series, layout);
72
+ if (yAxis === null || yAxis === void 0 ? void 0 : yAxis.tickformat) {
73
+ return {
74
+ yAxisTickFormat: d3Format(yAxis === null || yAxis === void 0 ? void 0 : yAxis.tickformat),
75
+ };
76
+ }
77
+ return {};
78
+ };
79
+ var getYMinMaxValues = function (series, layout) {
80
+ var _a;
81
+ var range = (_a = getYAxisProperties(series, layout)) === null || _a === void 0 ? void 0 : _a.range;
82
+ if (range && range.length === 2) {
83
+ return {
84
+ yMinValue: range[0],
85
+ yMaxValue: range[1],
86
+ };
87
+ }
88
+ return {};
89
+ };
90
+ var getYAxisProperties = function (series, layout) {
91
+ return layout === null || layout === void 0 ? void 0 : layout.yaxis;
92
+ };
93
+ var getXAxisProperties = function (series, layout) {
94
+ return layout === null || layout === void 0 ? void 0 : layout.xaxis;
95
+ };
96
+ var getFormattedCalloutYData = function (yVal, yAxisFormat) {
97
+ if (typeof (yAxisFormat === null || yAxisFormat === void 0 ? void 0 : yAxisFormat.yAxisTickFormat) === 'function' && typeof yVal === 'number') {
98
+ return yAxisFormat.yAxisTickFormat(yVal);
99
+ }
100
+ return formatToLocaleString(yVal);
101
+ };
59
102
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
60
103
  export var correctYearMonth = function (xValues) {
61
104
  var presentYear = new Date().getFullYear();
@@ -203,7 +246,7 @@ export var transformPlotlyJsonToDonutProps = function (input, isMultiPlot, color
203
246
  chartTitle: chartTitle,
204
247
  chartData: Object.values(mapLegendToDataPoint),
205
248
  },
206
- hideLegend: ((_p = input.layout) === null || _p === void 0 ? void 0 : _p.showlegend) === false ? true : false,
249
+ hideLegend: isMultiPlot || ((_p = input.layout) === null || _p === void 0 ? void 0 : _p.showlegend) === false,
207
250
  width: (_q = input.layout) === null || _q === void 0 ? void 0 : _q.width,
208
251
  height: height,
209
252
  innerRadius: innerRadius,
@@ -220,6 +263,7 @@ export var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorM
220
263
  var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
221
264
  var _d = getLegendProps(input.data, input.layout, isMultiPlot), legends = _d.legends, hideLegend = _d.hideLegend;
222
265
  var colorScale = undefined;
266
+ var yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
223
267
  input.data.forEach(function (series, index1) {
224
268
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
225
269
  if (((_c = (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.coloraxis) === null || _b === void 0 ? void 0 : _b.colorscale) === null || _c === void 0 ? void 0 : _c.length) &&
@@ -260,11 +304,13 @@ export var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorM
260
304
  : resolveColor(extractedBarColors, index2, legend, colorMap, isDarkTheme);
261
305
  var opacity = getOpacity(series, index2);
262
306
  var yVal = rangeYValues[index2];
307
+ var yAxisCalloutData = getFormattedCalloutYData(yVal, yAxisTickFormat);
263
308
  if (series.type === 'bar') {
264
309
  mapXToDataPoints[x].chartData.push({
265
310
  legend: legend,
266
311
  data: yVal,
267
312
  color: (_e = rgb(color).copy({ opacity: opacity }).formatHex8()) !== null && _e !== void 0 ? _e : color,
313
+ yAxisCalloutData: yAxisCalloutData,
268
314
  });
269
315
  if (typeof yVal === 'number') {
270
316
  yMaxValue = Math.max(yMaxValue, yVal);
@@ -281,6 +327,7 @@ export var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorM
281
327
  color: (_f = rgb(lineColor).copy({ opacity: opacity }).formatHex8()) !== null && _f !== void 0 ? _f : color,
282
328
  lineOptions: __assign(__assign({}, (lineOptions !== null && lineOptions !== void 0 ? lineOptions : {})), { mode: series.mode }),
283
329
  useSecondaryYScale: usesSecondaryYScale(series, input.layout),
330
+ yAxisCalloutData: yAxisCalloutData,
284
331
  });
285
332
  if (!usesSecondaryYScale(series, input.layout) && typeof yVal === 'number') {
286
333
  yMaxValue = Math.max(yMaxValue, yVal);
@@ -290,8 +337,7 @@ export var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorM
290
337
  });
291
338
  });
292
339
  });
293
- var _e = getTitles(input.layout), chartTitle = _e.chartTitle, xAxisTitle = _e.xAxisTitle, yAxisTitle = _e.yAxisTitle;
294
- return __assign(__assign(__assign({ data: Object.values(mapXToDataPoints), width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, barWidth: 'auto', yMaxValue: yMaxValue, yMinValue: yMinValue, chartTitle: chartTitle, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle, mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true, supportNegativeData: true, barGapMax: 2, showYAxisLables: true, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true }), getAxisCategoryOrderProps(input.data, input.layout));
340
+ return __assign(__assign(__assign(__assign(__assign(__assign({ data: Object.values(mapXToDataPoints), width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, barWidth: 'auto', yMaxValue: yMaxValue, yMinValue: yMinValue, mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true, supportNegativeData: true, barGapMax: 2, showYAxisLables: true, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true }), getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getXAxisTickFormat(input.data[0], input.layout)), yAxisTickFormat);
295
341
  };
296
342
  var createColorScale = function (layout, series) {
297
343
  var _a, _b, _c, _d, _e, _f;
@@ -315,6 +361,7 @@ export var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorM
315
361
  var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, 0, 0);
316
362
  var _d = getLegendProps(input.data, input.layout, isMultiPlot), legends = _d.legends, hideLegend = _d.hideLegend;
317
363
  var colorScale = undefined;
364
+ var yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
318
365
  input.data.forEach(function (series, index1) {
319
366
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
320
367
  if (((_c = (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.coloraxis) === null || _b === void 0 ? void 0 : _b.colorscale) === null || _c === void 0 ? void 0 : _c.length) &&
@@ -342,19 +389,20 @@ export var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorM
342
389
  : 0)
343
390
  : resolveColor(extractedColors, xIndex, legend, colorMap, isDarkTheme);
344
391
  var opacity = getOpacity(series, xIndex);
392
+ var yVal = series.y[xIndex];
345
393
  mapXToDataPoints[x].series.push({
346
394
  key: legend,
347
- data: series.y[xIndex],
395
+ data: yVal,
348
396
  xAxisCalloutData: x,
349
397
  color: (_f = rgb(color).copy({ opacity: opacity }).formatHex8()) !== null && _f !== void 0 ? _f : color,
350
398
  legend: legend,
351
399
  useSecondaryYScale: usesSecondaryYScale(series, input.layout),
400
+ yAxisCalloutData: getFormattedCalloutYData(yVal, yAxisTickFormat),
352
401
  });
353
402
  }
354
403
  });
355
404
  });
356
- var _e = getTitles(input.layout), chartTitle = _e.chartTitle, xAxisTitle = _e.xAxisTitle, yAxisTitle = _e.yAxisTitle;
357
- return __assign(__assign(__assign({ data: Object.values(mapXToDataPoints), width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, barwidth: 'auto', chartTitle: chartTitle, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle, mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true }), getAxisCategoryOrderProps(input.data, input.layout));
405
+ return __assign(__assign(__assign(__assign(__assign(__assign(__assign({ data: Object.values(mapXToDataPoints), width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, barwidth: 'auto', mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true }), getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getYMinMaxValues(input.data[0], input.layout)), getXAxisTickFormat(input.data[0], input.layout)), yAxisTickFormat);
358
406
  };
359
407
  export var transformPlotlyJsonToVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
360
408
  var _a, _b, _c;
@@ -417,8 +465,7 @@ export var transformPlotlyJsonToVBCProps = function (input, isMultiPlot, colorMa
417
465
  : { xAxisCalloutData: "[".concat(bin.x0, " - ").concat(bin.x1, ")") })));
418
466
  });
419
467
  });
420
- var _e = getTitles(input.layout), chartTitle = _e.chartTitle, xAxisTitle = _e.xAxisTitle, yAxisTitle = _e.yAxisTitle;
421
- return __assign({ data: vbcData, width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, supportNegativeData: true, chartTitle: chartTitle, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle, mode: 'histogram', hideTickOverlap: true, maxBarWidth: 50, hideLegend: hideLegend, roundCorners: true }, getAxisCategoryOrderProps(input.data, input.layout));
468
+ return __assign(__assign(__assign({ data: vbcData, width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, supportNegativeData: true, mode: 'histogram', hideTickOverlap: true, maxBarWidth: 50, hideLegend: hideLegend, roundCorners: true }, getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getYMinMaxValues(input.data[0], input.layout));
422
469
  };
423
470
  export var transformPlotlyJsonToAreaChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
424
471
  return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'area', colorMap, colorwayType, isDarkTheme);
@@ -430,7 +477,7 @@ export var transformPlotlyJsonToScatterChartProps = function (input, isMultiPlot
430
477
  return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'scatter', colorMap, colorwayType, isDarkTheme);
431
478
  };
432
479
  var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme) {
433
- var _a, _b, _c, _d, _e, _f, _g;
480
+ var _a, _b, _c, _d;
434
481
  var isScatterMarkers = [
435
482
  'markers',
436
483
  'text+markers',
@@ -443,7 +490,8 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
443
490
  var isScatterChart = chartType === 'scatter';
444
491
  var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
445
492
  var mode = 'tonexty';
446
- var _h = getLegendProps(input.data, input.layout, isMultiPlot), legends = _h.legends, hideLegend = _h.hideLegend;
493
+ var _e = getLegendProps(input.data, input.layout, isMultiPlot), legends = _e.legends, hideLegend = _e.hideLegend;
494
+ var yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
447
495
  var chartData = input.data
448
496
  .map(function (series, index) {
449
497
  var _a, _b, _c, _d, _e, _f, _g;
@@ -481,11 +529,11 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
481
529
  legendShape: legendShape,
482
530
  data: rangeXValues.map(function (x, i) {
483
531
  var _a, _b;
484
- return (__assign(__assign({ x: resolveXAxisPoint(x, isXYearCategory, isXString, isXDate, isXNumber), y: rangeYValues[i] }, (Array.isArray((_a = series.marker) === null || _a === void 0 ? void 0 : _a.size)
532
+ return (__assign(__assign(__assign({ x: resolveXAxisPoint(x, isXYearCategory, isXString, isXDate, isXNumber), y: rangeYValues[i] }, (Array.isArray((_a = series.marker) === null || _a === void 0 ? void 0 : _a.size)
485
533
  ? { markerSize: markerSizes[i] }
486
534
  : typeof ((_b = series.marker) === null || _b === void 0 ? void 0 : _b.size) === 'number'
487
535
  ? { markerSize: series.marker.size }
488
- : {})), (textValues ? { text: textValues[i] } : {})));
536
+ : {})), (textValues ? { text: textValues[i] } : {})), { yAxisCalloutData: getFormattedCalloutYData(rangeYValues[i], yAxisTickFormat) }));
489
537
  }),
490
538
  color: (_c = rgb(seriesColor).copy({ opacity: seriesOpacity }).formatHex8()) !== null && _c !== void 0 ? _c : seriesColor,
491
539
  lineOptions: __assign(__assign({}, (lineOptions !== null && lineOptions !== void 0 ? lineOptions : {})), { mode: series.mode }),
@@ -494,22 +542,25 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
494
542
  });
495
543
  })
496
544
  .flat();
497
- var yMinMaxValues = findNumericMinMaxOfY(chartData);
498
- var _j = getTitles(input.layout), chartTitle = _j.chartTitle, xAxisTitle = _j.xAxisTitle, yAxisTitle = _j.yAxisTitle;
545
+ var yMinMax = getYMinMaxValues(input.data[0], input.layout);
546
+ if (yMinMax.yMinValue === undefined && yMinMax.yMaxValue === undefined) {
547
+ var yMinMaxValues = findNumericMinMaxOfY(chartData);
548
+ yMinMax.yMinValue = yMinMaxValues.startValue;
549
+ yMinMax.yMaxValue = yMinMaxValues.endValue;
550
+ }
499
551
  var numDataPoints = chartData.reduce(function (total, lineChartPoints) { return total + lineChartPoints.data.length; }, 0);
500
552
  var chartProps = {
501
- chartTitle: chartTitle,
502
553
  lineChartData: chartData,
503
554
  };
504
555
  var scatterChartProps = {
505
- chartTitle: chartTitle,
506
556
  scatterChartData: chartData,
507
557
  };
558
+ var commonProps = __assign(__assign(__assign(__assign(__assign({ supportNegativeData: true }, secondaryYAxisValues), { width: (_b = input.layout) === null || _b === void 0 ? void 0 : _b.width, height: (_d = (_c = input.layout) === null || _c === void 0 ? void 0 : _c.height) !== null && _d !== void 0 ? _d : 350, hideTickOverlap: true, hideLegend: hideLegend, useUTC: false, optimizeLargeData: numDataPoints > 1000 }), getTitles(input.layout)), getXAxisTickFormat(input.data[0], input.layout)), yAxisTickFormat);
508
559
  if (isAreaChart) {
509
- return __assign(__assign({ data: chartProps, supportNegativeData: true, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle }, secondaryYAxisValues), { mode: mode, width: (_b = input.layout) === null || _b === void 0 ? void 0 : _b.width, height: (_d = (_c = input.layout) === null || _c === void 0 ? void 0 : _c.height) !== null && _d !== void 0 ? _d : 350, hideTickOverlap: true, hideLegend: hideLegend, useUTC: false, optimizeLargeData: numDataPoints > 1000 });
560
+ return __assign({ data: chartProps, mode: mode }, commonProps);
510
561
  }
511
562
  else {
512
- return __assign(__assign({ data: isScatterChart ? scatterChartProps : chartProps, supportNegativeData: true, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle }, secondaryYAxisValues), { roundedTicks: true, yMinValue: yMinMaxValues.startValue, yMaxValue: yMinMaxValues.endValue, width: (_e = input.layout) === null || _e === void 0 ? void 0 : _e.width, height: (_g = (_f = input.layout) === null || _f === void 0 ? void 0 : _f.height) !== null && _g !== void 0 ? _g : 350, hideTickOverlap: true, enableReflow: false, hideLegend: hideLegend, useUTC: false, optimizeLargeData: numDataPoints > 1000 });
563
+ return __assign(__assign({ data: isScatterChart ? scatterChartProps : chartProps, roundedTicks: true, enableReflow: false }, commonProps), yMinMax);
513
564
  }
514
565
  };
515
566
  export var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
@@ -559,10 +610,9 @@ export var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, is
559
610
  var scalingFactor = 0.01;
560
611
  var gapFactor = 1 / (1 + scalingFactor * numberOfRows);
561
612
  var barHeight = availableHeight / (numberOfRows * (1 + gapFactor));
562
- var _t = getTitles(input.layout), chartTitle = _t.chartTitle, xAxisTitle = _t.xAxisTitle, yAxisTitle = _t.yAxisTitle;
563
- return __assign({ data: chartData, chartTitle: chartTitle, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle, secondaryYAxistitle: typeof ((_k = (_j = input.layout) === null || _j === void 0 ? void 0 : _j.yaxis2) === null || _k === void 0 ? void 0 : _k.title) === 'string'
613
+ return __assign(__assign({ data: chartData, secondaryYAxistitle: typeof ((_k = (_j = input.layout) === null || _j === void 0 ? void 0 : _j.yaxis2) === null || _k === void 0 ? void 0 : _k.title) === 'string'
564
614
  ? (_m = (_l = input.layout) === null || _l === void 0 ? void 0 : _l.yaxis2) === null || _m === void 0 ? void 0 : _m.title
565
- : ((_q = (_p = (_o = input.layout) === null || _o === void 0 ? void 0 : _o.yaxis2) === null || _p === void 0 ? void 0 : _p.title) === null || _q === void 0 ? void 0 : _q.text) || '', barHeight: barHeight, showYAxisLables: true, height: chartHeight, width: (_r = input.layout) === null || _r === void 0 ? void 0 : _r.width, hideTickOverlap: true, hideLegend: hideLegend, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, roundCorners: true }, getAxisCategoryOrderProps(input.data, input.layout));
615
+ : ((_q = (_p = (_o = input.layout) === null || _o === void 0 ? void 0 : _o.yaxis2) === null || _p === void 0 ? void 0 : _p.title) === null || _q === void 0 ? void 0 : _q.text) || '', barHeight: barHeight, showYAxisLables: true, height: chartHeight, width: (_r = input.layout) === null || _r === void 0 ? void 0 : _r.width, hideTickOverlap: true, hideLegend: hideLegend, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, roundCorners: true }, getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout));
566
616
  };
567
617
  export var transformPlotlyJsonToHeatmapProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
568
618
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8;
@@ -676,8 +726,7 @@ export var transformPlotlyJsonToHeatmapProps = function (input, isMultiPlot, col
676
726
  var rangeValuesForColorScale = Array.isArray(colorscale)
677
727
  ? colorscale.map(function (arr) { return arr[1]; })
678
728
  : defaultRange;
679
- var _9 = getTitles(input.layout), chartTitle = _9.chartTitle, xAxisTitle = _9.xAxisTitle, yAxisTitle = _9.yAxisTitle;
680
- return __assign({ data: [heatmapData], domainValuesForColorScale: domainValuesForColorScale, rangeValuesForColorScale: rangeValuesForColorScale, hideLegend: true, showYAxisLables: true, chartTitle: chartTitle, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle, sortOrder: 'none', width: (_6 = input.layout) === null || _6 === void 0 ? void 0 : _6.width, height: (_8 = (_7 = input.layout) === null || _7 === void 0 ? void 0 : _7.height) !== null && _8 !== void 0 ? _8 : 350, hideTickOverlap: true, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true }, getAxisCategoryOrderProps([firstData], input.layout));
729
+ return __assign(__assign({ data: [heatmapData], domainValuesForColorScale: domainValuesForColorScale, rangeValuesForColorScale: rangeValuesForColorScale, hideLegend: true, showYAxisLables: true, sortOrder: 'none', width: (_6 = input.layout) === null || _6 === void 0 ? void 0 : _6.width, height: (_8 = (_7 = input.layout) === null || _7 === void 0 ? void 0 : _7.height) !== null && _8 !== void 0 ? _8 : 350, hideTickOverlap: true, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true }, getTitles(input.layout)), getAxisCategoryOrderProps([firstData], input.layout));
681
730
  };
682
731
  export var transformPlotlyJsonToSankeyProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
683
732
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
@@ -1133,26 +1182,44 @@ var getLegendShape = function (series) {
1133
1182
  }
1134
1183
  return 'default';
1135
1184
  };
1136
- export var getAllupLegendsProps = function (input, colorMap, colorwayType, isDarkTheme) {
1185
+ export var getAllupLegendsProps = function (input, colorMap, colorwayType, traceInfo, isDarkTheme) {
1137
1186
  var allupLegends = [];
1138
1187
  // reduce on showlegend boolean propperty. reduce should return true if at least one series has showlegend true
1139
1188
  var toShowLegend = input.data.reduce(function (acc, series) {
1140
- return acc || series.showlegend === true;
1189
+ return (acc || series.showlegend === true || series.showlegend === undefined);
1141
1190
  }, false);
1142
1191
  if (toShowLegend) {
1143
1192
  input.data.forEach(function (series, index) {
1144
- var _a, _b, _c, _d, _e;
1145
- var name = series.legendgroup;
1146
- var color = ((_a = series.line) === null || _a === void 0 ? void 0 : _a.color) || ((_b = series.marker) === null || _b === void 0 ? void 0 : _b.color);
1147
- var legendShape = getLegendShape(series);
1148
- var resolvedColor = extractColor((_e = (_d = (_c = input.layout) === null || _c === void 0 ? void 0 : _c.template) === null || _d === void 0 ? void 0 : _d.layout) === null || _e === void 0 ? void 0 : _e.colorway, colorwayType, color, colorMap, isDarkTheme);
1149
- if (name !== undefined && allupLegends.some(function (group) { return group.title === name; }) === false) {
1150
- allupLegends.push({
1151
- title: name,
1152
- color: resolvedColor,
1153
- shape: legendShape,
1193
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
1194
+ if (traceInfo[index].type === 'donut') {
1195
+ var pieSeries = series;
1196
+ var colors_1 = extractColor((_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.piecolorway) !== null && _b !== void 0 ? _b : (_e = (_d = (_c = input.layout) === null || _c === void 0 ? void 0 : _c.template) === null || _d === void 0 ? void 0 : _d.layout) === null || _e === void 0 ? void 0 : _e.colorway, colorwayType, (_g = (_f = input.layout) === null || _f === void 0 ? void 0 : _f.piecolorway) !== null && _g !== void 0 ? _g : (_h = pieSeries === null || pieSeries === void 0 ? void 0 : pieSeries.marker) === null || _h === void 0 ? void 0 : _h.colors, colorMap, isDarkTheme);
1197
+ (_j = pieSeries.labels) === null || _j === void 0 ? void 0 : _j.forEach(function (label, labelIndex) {
1198
+ var legend = "".concat(label);
1199
+ // resolve color for each legend from the extracted colors
1200
+ var color = resolveColor(colors_1, labelIndex, legend, colorMap, isDarkTheme);
1201
+ if (legend !== '' && allupLegends.some(function (group) { return group.title === legend; }) === false) {
1202
+ allupLegends.push({
1203
+ title: legend,
1204
+ color: color,
1205
+ });
1206
+ }
1154
1207
  });
1155
1208
  }
1209
+ else if (isNonPlotType(traceInfo[index].type) === false) {
1210
+ var plotSeries = series;
1211
+ var name_1 = plotSeries.legendgroup;
1212
+ var color = ((_k = plotSeries.line) === null || _k === void 0 ? void 0 : _k.color) || ((_l = plotSeries.marker) === null || _l === void 0 ? void 0 : _l.color);
1213
+ var legendShape = getLegendShape(plotSeries);
1214
+ var resolvedColor = extractColor((_p = (_o = (_m = input.layout) === null || _m === void 0 ? void 0 : _m.template) === null || _o === void 0 ? void 0 : _o.layout) === null || _p === void 0 ? void 0 : _p.colorway, colorwayType, color, colorMap, isDarkTheme);
1215
+ if (name_1 !== undefined && name_1 !== '' && allupLegends.some(function (group) { return group.title === name_1; }) === false) {
1216
+ allupLegends.push({
1217
+ title: name_1,
1218
+ color: resolvedColor,
1219
+ shape: legendShape,
1220
+ });
1221
+ }
1222
+ }
1156
1223
  });
1157
1224
  }
1158
1225
  return {
@@ -1212,153 +1279,162 @@ var getIndexFromKey = function (key, pattern) {
1212
1279
  var normalizedKey = key.replace(pattern, '') === '' ? '1' : key.replace(pattern, '');
1213
1280
  return parseInt(normalizedKey, 10) - 1;
1214
1281
  };
1215
- export var getGridProperties = function (layout, isMultiPlot) {
1282
+ export var isNonPlotType = function (chartType) {
1283
+ return ['donut', 'sankey', 'pie'].includes(chartType);
1284
+ };
1285
+ export var getGridProperties = function (schema, isMultiPlot, validTracesInfo) {
1216
1286
  var _a;
1217
- var gridX = [];
1218
- var gridY = [];
1287
+ var domainX = [];
1288
+ var domainY = [];
1289
+ var cartesianDomains = 0;
1219
1290
  var annotations = {};
1220
1291
  var templateRows = '1fr';
1221
1292
  var templateColumns = '1fr';
1222
1293
  var gridLayout = {};
1223
- if (layout === undefined || layout === null || Object.keys(layout).length === 0) {
1224
- return { templateRows: templateRows, templateColumns: templateColumns, layout: gridLayout };
1225
- }
1226
- if (!layout.xaxis || !layout.yaxis) {
1227
- return { templateRows: templateRows, templateColumns: templateColumns, layout: gridLayout };
1228
- }
1229
1294
  if (!isMultiPlot) {
1230
1295
  return { templateRows: templateRows, templateColumns: templateColumns, layout: gridLayout };
1231
1296
  }
1232
- Object.keys(layout).forEach(function (key) {
1233
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1234
- if (key.startsWith('xaxis')) {
1235
- var index = getIndexFromKey(key, 'xaxis');
1236
- var anchor = (_b = (_a = layout[key]) === null || _a === void 0 ? void 0 : _a.anchor) !== null && _b !== void 0 ? _b : 'y';
1237
- var anchorIndex = getIndexFromKey(anchor, 'y');
1238
- if (index !== anchorIndex) {
1239
- throw new Error("Invalid layout: xaxis ".concat(index + 1, " anchor should be y").concat(anchorIndex + 1));
1297
+ var layout = schema === null || schema === void 0 ? void 0 : schema.layout;
1298
+ if (layout !== undefined && layout !== null && Object.keys(layout).length > 0) {
1299
+ Object.keys(layout !== null && layout !== void 0 ? layout : {}).forEach(function (key) {
1300
+ var _a, _b, _c, _d, _e;
1301
+ if (key.startsWith('xaxis')) {
1302
+ var index = getIndexFromKey(key, 'xaxis');
1303
+ var anchor = (_b = (_a = layout[key]) === null || _a === void 0 ? void 0 : _a.anchor) !== null && _b !== void 0 ? _b : 'y';
1304
+ var anchorIndex = getIndexFromKey(anchor, 'y');
1305
+ if (index !== anchorIndex) {
1306
+ throw new Error("Invalid layout: xaxis ".concat(index + 1, " anchor should be y").concat(anchorIndex + 1));
1307
+ }
1308
+ var xAxisLayout = layout[key];
1309
+ var domainXInfo = {
1310
+ start: (xAxisLayout === null || xAxisLayout === void 0 ? void 0 : xAxisLayout.domain) ? xAxisLayout.domain[0] : 0,
1311
+ end: (xAxisLayout === null || xAxisLayout === void 0 ? void 0 : xAxisLayout.domain) ? xAxisLayout.domain[1] : 1,
1312
+ };
1313
+ domainX.push(domainXInfo);
1240
1314
  }
1241
- gridX[index] = (_d = (_c = layout[key]) === null || _c === void 0 ? void 0 : _c.domain) !== null && _d !== void 0 ? _d : [];
1242
- }
1243
- else if (key.startsWith('yaxis')) {
1244
- var index = getIndexFromKey(key, 'yaxis');
1245
- var anchor = (_f = (_e = layout[key]) === null || _e === void 0 ? void 0 : _e.anchor) !== null && _f !== void 0 ? _f : 'x';
1246
- var anchorIndex = getIndexFromKey(anchor, 'x');
1247
- if (index !== anchorIndex) {
1248
- if ((index === 1 && anchorIndex === 0) || ((_g = layout.yaxis2) === null || _g === void 0 ? void 0 : _g.side) === 'right') {
1249
- // Special case for secondary y axis where yaxis2 can anchor to x1
1250
- return { templateRows: templateRows, templateColumns: templateColumns };
1315
+ else if (key.startsWith('yaxis')) {
1316
+ var index = getIndexFromKey(key, 'yaxis');
1317
+ var anchor = (_d = (_c = layout[key]) === null || _c === void 0 ? void 0 : _c.anchor) !== null && _d !== void 0 ? _d : 'x';
1318
+ var anchorIndex = getIndexFromKey(anchor, 'x');
1319
+ if (index !== anchorIndex) {
1320
+ if ((index === 1 && anchorIndex === 0) || ((_e = layout.yaxis2) === null || _e === void 0 ? void 0 : _e.side) === 'right') {
1321
+ // Special case for secondary y axis where yaxis2 can anchor to x1
1322
+ return { templateRows: templateRows, templateColumns: templateColumns };
1323
+ }
1324
+ throw new Error("Invalid layout: yaxis ".concat(index + 1, " anchor should be x").concat(anchorIndex + 1));
1251
1325
  }
1252
- throw new Error("Invalid layout: yaxis ".concat(index + 1, " anchor should be x").concat(anchorIndex + 1));
1326
+ var yAxisLayout = layout[key];
1327
+ var domainYInfo = {
1328
+ start: (yAxisLayout === null || yAxisLayout === void 0 ? void 0 : yAxisLayout.domain) ? yAxisLayout.domain[0] : 0,
1329
+ end: (yAxisLayout === null || yAxisLayout === void 0 ? void 0 : yAxisLayout.domain) ? yAxisLayout.domain[1] : 1,
1330
+ };
1331
+ domainY.push(domainYInfo);
1253
1332
  }
1254
- gridY[index] = (_j = (_h = layout[key]) === null || _h === void 0 ? void 0 : _h.domain) !== null && _j !== void 0 ? _j : [];
1255
- }
1256
- });
1257
- (_a = layout.annotations) === null || _a === void 0 ? void 0 : _a.forEach(function (annotation) {
1258
- var xMatches = gridX.flatMap(function (interval, idx) {
1259
- return (annotation === null || annotation === void 0 ? void 0 : annotation.x) >= interval[0] && (annotation === null || annotation === void 0 ? void 0 : annotation.x) <= interval[1] ? [idx] : [];
1260
1333
  });
1261
- var yMatch = gridY.findIndex(function (interval, yIndex) {
1262
- return xMatches.includes(yIndex) &&
1263
- (annotation === null || annotation === void 0 ? void 0 : annotation.y) >= interval[0] &&
1264
- (annotation === null || annotation === void 0 ? void 0 : annotation.y) <= interval[1];
1265
- });
1266
- if (yMatch !== -1) {
1267
- if (annotations[yMatch] === undefined) {
1268
- annotations[yMatch] = {};
1269
- }
1270
- if ((annotation === null || annotation === void 0 ? void 0 : annotation.textangle) === 90) {
1271
- annotations[yMatch].yAnnotation = annotation.text;
1272
- }
1273
- else {
1274
- annotations[yMatch].xAnnotation = annotation.text;
1275
- }
1334
+ }
1335
+ cartesianDomains = domainX.length; // Assuming that the number of x and y axes is the same
1336
+ validTracesInfo.forEach(function (trace, index) {
1337
+ var _a, _b, _c, _d, _e;
1338
+ if (isNonPlotType(trace.type)) {
1339
+ var series = (_a = schema === null || schema === void 0 ? void 0 : schema.data) === null || _a === void 0 ? void 0 : _a[index];
1340
+ var domainXInfo = {
1341
+ start: ((_b = series.domain) === null || _b === void 0 ? void 0 : _b.x) ? series.domain.x[0] : 0,
1342
+ end: ((_c = series.domain) === null || _c === void 0 ? void 0 : _c.x) ? series.domain.x[1] : 1,
1343
+ };
1344
+ var domainYInfo = {
1345
+ start: ((_d = series.domain) === null || _d === void 0 ? void 0 : _d.y) ? series.domain.y[0] : 0,
1346
+ end: ((_e = series.domain) === null || _e === void 0 ? void 0 : _e.y) ? series.domain.y[1] : 1,
1347
+ };
1348
+ domainX.push(domainXInfo);
1349
+ domainY.push(domainYInfo);
1276
1350
  }
1277
1351
  });
1278
- if (gridX.length > 0) {
1352
+ if (layout !== undefined && layout !== null && Object.keys(layout).length > 0) {
1353
+ (_a = layout.annotations) === null || _a === void 0 ? void 0 : _a.forEach(function (annotation) {
1354
+ var xMatches = domainX.flatMap(function (interval, idx) {
1355
+ return (annotation === null || annotation === void 0 ? void 0 : annotation.x) >= interval.start && (annotation === null || annotation === void 0 ? void 0 : annotation.x) <= interval.end ? [idx] : [];
1356
+ });
1357
+ var yMatch = domainY.findIndex(function (interval, yIndex) {
1358
+ return xMatches.includes(yIndex) &&
1359
+ (annotation === null || annotation === void 0 ? void 0 : annotation.y) >= interval.start &&
1360
+ (annotation === null || annotation === void 0 ? void 0 : annotation.y) <= interval.end;
1361
+ });
1362
+ if (yMatch !== -1) {
1363
+ if (annotations[yMatch] === undefined) {
1364
+ annotations[yMatch] = {};
1365
+ }
1366
+ if ((annotation === null || annotation === void 0 ? void 0 : annotation.textangle) === 90) {
1367
+ annotations[yMatch].yAnnotation = annotation.text;
1368
+ }
1369
+ else {
1370
+ annotations[yMatch].xAnnotation = annotation.text;
1371
+ }
1372
+ }
1373
+ });
1374
+ }
1375
+ if (domainX.length > 0) {
1279
1376
  var uniqueXIntervals_1 = new Map();
1280
- gridX.forEach(function (interval) {
1281
- var key = "".concat(interval[0], "-").concat(interval[1]);
1377
+ domainX.forEach(function (interval) {
1378
+ var key = "".concat(interval.start, "-").concat(interval.end);
1282
1379
  if (!uniqueXIntervals_1.has(key)) {
1283
1380
  uniqueXIntervals_1.set(key, interval);
1284
1381
  }
1285
1382
  });
1286
- var minXInterval_1 = Math.min.apply(Math, Array.from(uniqueXIntervals_1.values()).map(function (interval) { return interval[1] - interval[0]; }));
1287
- templateColumns = Array.from(uniqueXIntervals_1.values())
1288
- .map(function (interval) { return "".concat((interval[1] - interval[0]) / minXInterval_1, "fr"); })
1289
- .join(' ');
1290
- var columnNumber_1 = 1;
1291
- var lastIntervalEnd_1 = 0;
1292
- gridX.forEach(function (interval, index) {
1293
- if (interval.length === 0) {
1294
- return;
1295
- }
1296
- var cellName = "x".concat(index === 0 ? '' : index + 1);
1383
+ var sortedXStart_1 = Array.from(uniqueXIntervals_1.values())
1384
+ .map(function (interval) { return interval.start; })
1385
+ .sort();
1386
+ templateColumns = "repeat(".concat(sortedXStart_1.length, ", 1fr)");
1387
+ domainX.forEach(function (interval, index) {
1388
+ var cellName = index >= cartesianDomains
1389
+ ? "".concat(NON_PLOT_KEY_PREFIX).concat(index - cartesianDomains + 1)
1390
+ : "x".concat(index === 0 ? '' : index + 1);
1391
+ var columnIndex = sortedXStart_1.findIndex(function (start) { return start === interval.start; });
1392
+ var columnNumber = columnIndex + 1; // Column numbers are 1-based
1297
1393
  var annotationProps = annotations[index];
1298
1394
  var xAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.xAnnotation;
1299
- if (interval[0] < lastIntervalEnd_1) {
1300
- columnNumber_1 = 1;
1301
- }
1302
- lastIntervalEnd_1 = interval[1];
1303
1395
  var row = {
1304
1396
  row: -1,
1305
- column: columnNumber_1,
1397
+ column: columnNumber,
1306
1398
  xAnnotation: xAnnotation,
1399
+ xDomain: interval,
1400
+ yDomain: { start: 0, end: 1 }, // Default yDomain for x-axis
1307
1401
  };
1308
1402
  gridLayout[cellName] = row;
1309
- columnNumber_1 += 1;
1310
1403
  });
1311
1404
  }
1312
- var numColumns = Math.max.apply(Math, Object.values(gridLayout).map(function (cell) { var _a; return (_a = cell.column) !== null && _a !== void 0 ? _a : 0; }));
1313
- var columnFill = {};
1314
- for (var i = 1; i <= numColumns; i++) {
1315
- columnFill[i] = { row: 1, fillDomain: 0 };
1316
- }
1317
- if (gridY.length > 0) {
1405
+ if (domainY.length > 0) {
1318
1406
  var uniqueYIntervals_1 = new Map();
1319
- gridY.forEach(function (interval) {
1320
- var key = "".concat(interval[0], "-").concat(interval[1]);
1407
+ domainY.forEach(function (interval) {
1408
+ var key = "".concat(interval.start, "-").concat(interval.end);
1321
1409
  if (!uniqueYIntervals_1.has(key)) {
1322
1410
  uniqueYIntervals_1.set(key, interval);
1323
1411
  }
1324
1412
  });
1325
- var minYInterval_1 = Math.min.apply(Math, Array.from(uniqueYIntervals_1.values()).map(function (interval) { return interval[1] - interval[0]; }));
1326
- templateRows = Array.from(uniqueYIntervals_1.values())
1327
- .map(function (interval) { return "".concat((interval[1] - interval[0]) / minYInterval_1, "fr"); })
1328
- .join(' ');
1329
- gridY.forEach(function (interval, index) {
1330
- if (interval.length === 0) {
1331
- return;
1332
- }
1333
- var cellName = "x".concat(index === 0 ? '' : index + 1);
1413
+ var sortedYStart_1 = Array.from(uniqueYIntervals_1.values())
1414
+ .map(function (interval) { return interval.start; })
1415
+ .sort();
1416
+ var numberOfRows_1 = sortedYStart_1.length;
1417
+ templateRows = "repeat(".concat(numberOfRows_1, ", 1fr)");
1418
+ domainY.forEach(function (interval, index) {
1419
+ var cellName = index >= cartesianDomains
1420
+ ? "".concat(NON_PLOT_KEY_PREFIX).concat(index - cartesianDomains + 1)
1421
+ : "x".concat(index === 0 ? '' : index + 1);
1422
+ var rowIndex = sortedYStart_1.findIndex(function (start) { return start === interval.start; });
1423
+ var rowNumber = numberOfRows_1 - rowIndex; // Rows are 1-based and we need to reverse the order for CSS grid
1334
1424
  var annotationProps = annotations[index];
1335
1425
  var yAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.yAnnotation;
1336
1426
  var cell = gridLayout[cellName];
1337
1427
  if (cell !== undefined) {
1338
- cell.row = columnFill[cell.column].row;
1428
+ cell.row = rowNumber;
1339
1429
  cell.yAnnotation = yAnnotation;
1430
+ cell.yDomain = interval;
1340
1431
  }
1341
- columnFill[cell.column].fillDomain = interval[1];
1342
- columnFill[cell.column].row += 1;
1343
1432
  });
1344
1433
  }
1345
- // reverse the order of rows in grid layout from bottom-top to top-bottom as required by CSS grid
1346
- var reversedGridLayout = {};
1347
- // find the maximum row number
1348
- var maxRowNumber = Math.max.apply(Math, Object.values(gridLayout).map(function (cell) { var _a; return (_a = cell.row) !== null && _a !== void 0 ? _a : 0; }));
1349
- // iterate over the gridLayout and reverse the row numbers
1350
- Object.keys(gridLayout).forEach(function (key) {
1351
- var cell = gridLayout[key];
1352
- if (cell.row !== undefined) {
1353
- // reverse the row number
1354
- cell.row = maxRowNumber - cell.row + 1;
1355
- }
1356
- reversedGridLayout[key] = cell;
1357
- });
1358
1434
  return {
1359
1435
  templateRows: templateRows,
1360
1436
  templateColumns: templateColumns,
1361
- layout: reversedGridLayout,
1437
+ layout: gridLayout,
1362
1438
  };
1363
1439
  };
1364
1440
  /**