@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
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getGridProperties = exports.getValidXYRanges = exports.getNumberAtIndexOrDefault = exports.getAllupLegendsProps = exports.findArrayAttributes = exports.projectPolarToCartesian = exports.transformPlotlyJsonToChartTableProps = exports.transformPlotlyJsonToGaugeProps = exports.transformPlotlyJsonToSankeyProps = exports.transformPlotlyJsonToHeatmapProps = exports.transformPlotlyJsonToHorizontalBarWithAxisProps = exports.transformPlotlyJsonToScatterChartProps = exports.transformPlotlyJsonToLineChartProps = exports.transformPlotlyJsonToAreaChartProps = exports.transformPlotlyJsonToVBCProps = exports.transformPlotlyJsonToGVBCProps = exports.transformPlotlyJsonToVSBCProps = exports.transformPlotlyJsonToDonutProps = exports.resolveXAxisPoint = exports._getGaugeAxisColor = exports.correctYearMonth = void 0;
3
+ exports.getGridProperties = exports.isNonPlotType = exports.getValidXYRanges = exports.getNumberAtIndexOrDefault = exports.getAllupLegendsProps = exports.findArrayAttributes = exports.projectPolarToCartesian = exports.transformPlotlyJsonToChartTableProps = exports.transformPlotlyJsonToGaugeProps = exports.transformPlotlyJsonToSankeyProps = exports.transformPlotlyJsonToHeatmapProps = exports.transformPlotlyJsonToHorizontalBarWithAxisProps = exports.transformPlotlyJsonToScatterChartProps = exports.transformPlotlyJsonToLineChartProps = exports.transformPlotlyJsonToAreaChartProps = exports.transformPlotlyJsonToVBCProps = exports.transformPlotlyJsonToGVBCProps = exports.transformPlotlyJsonToVSBCProps = exports.transformPlotlyJsonToDonutProps = exports.resolveXAxisPoint = exports._getGaugeAxisColor = exports.correctYearMonth = exports.SINGLE_REPEAT = exports.NON_PLOT_KEY_PREFIX = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var d3_array_1 = require("d3-array");
6
6
  var d3_scale_1 = require("d3-scale");
@@ -12,6 +12,8 @@ var chart_utilities_1 = require("@fluentui/chart-utilities");
12
12
  var d3_shape_1 = require("d3-shape");
13
13
  var PlotlyColorAdapter_1 = require("./PlotlyColorAdapter");
14
14
  var d3_color_1 = require("d3-color");
15
+ exports.NON_PLOT_KEY_PREFIX = 'nonplot_';
16
+ exports.SINGLE_REPEAT = 'repeat(1, 1fr)';
15
17
  var dashOptions = {
16
18
  dot: {
17
19
  strokeDasharray: '1, 5',
@@ -59,6 +61,47 @@ function getTitles(layout) {
59
61
  };
60
62
  return titles;
61
63
  }
64
+ var getXAxisTickFormat = function (series, layout) {
65
+ var xAxis = getXAxisProperties(series, layout);
66
+ if (xAxis === null || xAxis === void 0 ? void 0 : xAxis.tickformat) {
67
+ return {
68
+ tickFormat: xAxis === null || xAxis === void 0 ? void 0 : xAxis.tickformat,
69
+ };
70
+ }
71
+ return {};
72
+ };
73
+ var getYAxisTickFormat = function (series, layout) {
74
+ var yAxis = getYAxisProperties(series, layout);
75
+ if (yAxis === null || yAxis === void 0 ? void 0 : yAxis.tickformat) {
76
+ return {
77
+ yAxisTickFormat: (0, d3_format_1.format)(yAxis === null || yAxis === void 0 ? void 0 : yAxis.tickformat),
78
+ };
79
+ }
80
+ return {};
81
+ };
82
+ var getYMinMaxValues = function (series, layout) {
83
+ var _a;
84
+ var range = (_a = getYAxisProperties(series, layout)) === null || _a === void 0 ? void 0 : _a.range;
85
+ if (range && range.length === 2) {
86
+ return {
87
+ yMinValue: range[0],
88
+ yMaxValue: range[1],
89
+ };
90
+ }
91
+ return {};
92
+ };
93
+ var getYAxisProperties = function (series, layout) {
94
+ return layout === null || layout === void 0 ? void 0 : layout.yaxis;
95
+ };
96
+ var getXAxisProperties = function (series, layout) {
97
+ return layout === null || layout === void 0 ? void 0 : layout.xaxis;
98
+ };
99
+ var getFormattedCalloutYData = function (yVal, yAxisFormat) {
100
+ if (typeof (yAxisFormat === null || yAxisFormat === void 0 ? void 0 : yAxisFormat.yAxisTickFormat) === 'function' && typeof yVal === 'number') {
101
+ return yAxisFormat.yAxisTickFormat(yVal);
102
+ }
103
+ return (0, chart_utilities_1.formatToLocaleString)(yVal);
104
+ };
62
105
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
63
106
  var correctYearMonth = function (xValues) {
64
107
  var presentYear = new Date().getFullYear();
@@ -209,7 +252,7 @@ var transformPlotlyJsonToDonutProps = function (input, isMultiPlot, colorMap, co
209
252
  chartTitle: chartTitle,
210
253
  chartData: Object.values(mapLegendToDataPoint),
211
254
  },
212
- hideLegend: ((_p = input.layout) === null || _p === void 0 ? void 0 : _p.showlegend) === false ? true : false,
255
+ hideLegend: isMultiPlot || ((_p = input.layout) === null || _p === void 0 ? void 0 : _p.showlegend) === false,
213
256
  width: (_q = input.layout) === null || _q === void 0 ? void 0 : _q.width,
214
257
  height: height,
215
258
  innerRadius: innerRadius,
@@ -227,6 +270,7 @@ var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorMap, col
227
270
  var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
228
271
  var _d = getLegendProps(input.data, input.layout, isMultiPlot), legends = _d.legends, hideLegend = _d.hideLegend;
229
272
  var colorScale = undefined;
273
+ var yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
230
274
  input.data.forEach(function (series, index1) {
231
275
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
232
276
  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) &&
@@ -267,11 +311,13 @@ var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorMap, col
267
311
  : (0, PlotlyColorAdapter_1.resolveColor)(extractedBarColors, index2, legend, colorMap, isDarkTheme);
268
312
  var opacity = (0, PlotlyColorAdapter_1.getOpacity)(series, index2);
269
313
  var yVal = rangeYValues[index2];
314
+ var yAxisCalloutData = getFormattedCalloutYData(yVal, yAxisTickFormat);
270
315
  if (series.type === 'bar') {
271
316
  mapXToDataPoints[x].chartData.push({
272
317
  legend: legend,
273
318
  data: yVal,
274
319
  color: (_e = (0, d3_color_1.rgb)(color).copy({ opacity: opacity }).formatHex8()) !== null && _e !== void 0 ? _e : color,
320
+ yAxisCalloutData: yAxisCalloutData,
275
321
  });
276
322
  if (typeof yVal === 'number') {
277
323
  yMaxValue = Math.max(yMaxValue, yVal);
@@ -288,6 +334,7 @@ var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorMap, col
288
334
  color: (_f = (0, d3_color_1.rgb)(lineColor).copy({ opacity: opacity }).formatHex8()) !== null && _f !== void 0 ? _f : color,
289
335
  lineOptions: tslib_1.__assign(tslib_1.__assign({}, (lineOptions !== null && lineOptions !== void 0 ? lineOptions : {})), { mode: series.mode }),
290
336
  useSecondaryYScale: usesSecondaryYScale(series, input.layout),
337
+ yAxisCalloutData: yAxisCalloutData,
291
338
  });
292
339
  if (!usesSecondaryYScale(series, input.layout) && typeof yVal === 'number') {
293
340
  yMaxValue = Math.max(yMaxValue, yVal);
@@ -297,8 +344,7 @@ var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorMap, col
297
344
  });
298
345
  });
299
346
  });
300
- var _e = getTitles(input.layout), chartTitle = _e.chartTitle, xAxisTitle = _e.xAxisTitle, yAxisTitle = _e.yAxisTitle;
301
- return tslib_1.__assign(tslib_1.__assign(tslib_1.__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));
347
+ return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__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);
302
348
  };
303
349
  exports.transformPlotlyJsonToVSBCProps = transformPlotlyJsonToVSBCProps;
304
350
  var createColorScale = function (layout, series) {
@@ -323,6 +369,7 @@ var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorMap, col
323
369
  var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, 0, 0);
324
370
  var _d = getLegendProps(input.data, input.layout, isMultiPlot), legends = _d.legends, hideLegend = _d.hideLegend;
325
371
  var colorScale = undefined;
372
+ var yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
326
373
  input.data.forEach(function (series, index1) {
327
374
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
328
375
  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) &&
@@ -350,19 +397,20 @@ var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorMap, col
350
397
  : 0)
351
398
  : (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, xIndex, legend, colorMap, isDarkTheme);
352
399
  var opacity = (0, PlotlyColorAdapter_1.getOpacity)(series, xIndex);
400
+ var yVal = series.y[xIndex];
353
401
  mapXToDataPoints[x].series.push({
354
402
  key: legend,
355
- data: series.y[xIndex],
403
+ data: yVal,
356
404
  xAxisCalloutData: x,
357
405
  color: (_f = (0, d3_color_1.rgb)(color).copy({ opacity: opacity }).formatHex8()) !== null && _f !== void 0 ? _f : color,
358
406
  legend: legend,
359
407
  useSecondaryYScale: usesSecondaryYScale(series, input.layout),
408
+ yAxisCalloutData: getFormattedCalloutYData(yVal, yAxisTickFormat),
360
409
  });
361
410
  }
362
411
  });
363
412
  });
364
- var _e = getTitles(input.layout), chartTitle = _e.chartTitle, xAxisTitle = _e.xAxisTitle, yAxisTitle = _e.yAxisTitle;
365
- return tslib_1.__assign(tslib_1.__assign(tslib_1.__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));
413
+ return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__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);
366
414
  };
367
415
  exports.transformPlotlyJsonToGVBCProps = transformPlotlyJsonToGVBCProps;
368
416
  var transformPlotlyJsonToVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
@@ -426,8 +474,7 @@ var transformPlotlyJsonToVBCProps = function (input, isMultiPlot, colorMap, colo
426
474
  : { xAxisCalloutData: "[".concat(bin.x0, " - ").concat(bin.x1, ")") })));
427
475
  });
428
476
  });
429
- var _e = getTitles(input.layout), chartTitle = _e.chartTitle, xAxisTitle = _e.xAxisTitle, yAxisTitle = _e.yAxisTitle;
430
- return tslib_1.__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));
477
+ return tslib_1.__assign(tslib_1.__assign(tslib_1.__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));
431
478
  };
432
479
  exports.transformPlotlyJsonToVBCProps = transformPlotlyJsonToVBCProps;
433
480
  var transformPlotlyJsonToAreaChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
@@ -443,7 +490,7 @@ var transformPlotlyJsonToScatterChartProps = function (input, isMultiPlot, color
443
490
  };
444
491
  exports.transformPlotlyJsonToScatterChartProps = transformPlotlyJsonToScatterChartProps;
445
492
  var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme) {
446
- var _a, _b, _c, _d, _e, _f, _g;
493
+ var _a, _b, _c, _d;
447
494
  var isScatterMarkers = [
448
495
  'markers',
449
496
  'text+markers',
@@ -456,7 +503,8 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
456
503
  var isScatterChart = chartType === 'scatter';
457
504
  var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
458
505
  var mode = 'tonexty';
459
- var _h = getLegendProps(input.data, input.layout, isMultiPlot), legends = _h.legends, hideLegend = _h.hideLegend;
506
+ var _e = getLegendProps(input.data, input.layout, isMultiPlot), legends = _e.legends, hideLegend = _e.hideLegend;
507
+ var yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
460
508
  var chartData = input.data
461
509
  .map(function (series, index) {
462
510
  var _a, _b, _c, _d, _e, _f, _g;
@@ -494,11 +542,11 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
494
542
  legendShape: legendShape,
495
543
  data: rangeXValues.map(function (x, i) {
496
544
  var _a, _b;
497
- return (tslib_1.__assign(tslib_1.__assign({ x: (0, exports.resolveXAxisPoint)(x, isXYearCategory, isXString, isXDate, isXNumber), y: rangeYValues[i] }, (Array.isArray((_a = series.marker) === null || _a === void 0 ? void 0 : _a.size)
545
+ return (tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ x: (0, exports.resolveXAxisPoint)(x, isXYearCategory, isXString, isXDate, isXNumber), y: rangeYValues[i] }, (Array.isArray((_a = series.marker) === null || _a === void 0 ? void 0 : _a.size)
498
546
  ? { markerSize: markerSizes[i] }
499
547
  : typeof ((_b = series.marker) === null || _b === void 0 ? void 0 : _b.size) === 'number'
500
548
  ? { markerSize: series.marker.size }
501
- : {})), (textValues ? { text: textValues[i] } : {})));
549
+ : {})), (textValues ? { text: textValues[i] } : {})), { yAxisCalloutData: getFormattedCalloutYData(rangeYValues[i], yAxisTickFormat) }));
502
550
  }),
503
551
  color: (_c = (0, d3_color_1.rgb)(seriesColor).copy({ opacity: seriesOpacity }).formatHex8()) !== null && _c !== void 0 ? _c : seriesColor,
504
552
  lineOptions: tslib_1.__assign(tslib_1.__assign({}, (lineOptions !== null && lineOptions !== void 0 ? lineOptions : {})), { mode: series.mode }),
@@ -507,22 +555,25 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
507
555
  });
508
556
  })
509
557
  .flat();
510
- var yMinMaxValues = (0, utilities_1.findNumericMinMaxOfY)(chartData);
511
- var _j = getTitles(input.layout), chartTitle = _j.chartTitle, xAxisTitle = _j.xAxisTitle, yAxisTitle = _j.yAxisTitle;
558
+ var yMinMax = getYMinMaxValues(input.data[0], input.layout);
559
+ if (yMinMax.yMinValue === undefined && yMinMax.yMaxValue === undefined) {
560
+ var yMinMaxValues = (0, utilities_1.findNumericMinMaxOfY)(chartData);
561
+ yMinMax.yMinValue = yMinMaxValues.startValue;
562
+ yMinMax.yMaxValue = yMinMaxValues.endValue;
563
+ }
512
564
  var numDataPoints = chartData.reduce(function (total, lineChartPoints) { return total + lineChartPoints.data.length; }, 0);
513
565
  var chartProps = {
514
- chartTitle: chartTitle,
515
566
  lineChartData: chartData,
516
567
  };
517
568
  var scatterChartProps = {
518
- chartTitle: chartTitle,
519
569
  scatterChartData: chartData,
520
570
  };
571
+ var commonProps = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__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);
521
572
  if (isAreaChart) {
522
- return tslib_1.__assign(tslib_1.__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 });
573
+ return tslib_1.__assign({ data: chartProps, mode: mode }, commonProps);
523
574
  }
524
575
  else {
525
- return tslib_1.__assign(tslib_1.__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 });
576
+ return tslib_1.__assign(tslib_1.__assign({ data: isScatterChart ? scatterChartProps : chartProps, roundedTicks: true, enableReflow: false }, commonProps), yMinMax);
526
577
  }
527
578
  };
528
579
  var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
@@ -572,10 +623,9 @@ var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, isMultiPl
572
623
  var scalingFactor = 0.01;
573
624
  var gapFactor = 1 / (1 + scalingFactor * numberOfRows);
574
625
  var barHeight = availableHeight / (numberOfRows * (1 + gapFactor));
575
- var _t = getTitles(input.layout), chartTitle = _t.chartTitle, xAxisTitle = _t.xAxisTitle, yAxisTitle = _t.yAxisTitle;
576
- return tslib_1.__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'
626
+ return tslib_1.__assign(tslib_1.__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'
577
627
  ? (_m = (_l = input.layout) === null || _l === void 0 ? void 0 : _l.yaxis2) === null || _m === void 0 ? void 0 : _m.title
578
- : ((_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));
628
+ : ((_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));
579
629
  };
580
630
  exports.transformPlotlyJsonToHorizontalBarWithAxisProps = transformPlotlyJsonToHorizontalBarWithAxisProps;
581
631
  var transformPlotlyJsonToHeatmapProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
@@ -690,8 +740,7 @@ var transformPlotlyJsonToHeatmapProps = function (input, isMultiPlot, colorMap,
690
740
  var rangeValuesForColorScale = Array.isArray(colorscale)
691
741
  ? colorscale.map(function (arr) { return arr[1]; })
692
742
  : defaultRange;
693
- var _9 = getTitles(input.layout), chartTitle = _9.chartTitle, xAxisTitle = _9.xAxisTitle, yAxisTitle = _9.yAxisTitle;
694
- return tslib_1.__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));
743
+ return tslib_1.__assign(tslib_1.__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));
695
744
  };
696
745
  exports.transformPlotlyJsonToHeatmapProps = transformPlotlyJsonToHeatmapProps;
697
746
  var transformPlotlyJsonToSankeyProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
@@ -1153,26 +1202,44 @@ var getLegendShape = function (series) {
1153
1202
  }
1154
1203
  return 'default';
1155
1204
  };
1156
- var getAllupLegendsProps = function (input, colorMap, colorwayType, isDarkTheme) {
1205
+ var getAllupLegendsProps = function (input, colorMap, colorwayType, traceInfo, isDarkTheme) {
1157
1206
  var allupLegends = [];
1158
1207
  // reduce on showlegend boolean propperty. reduce should return true if at least one series has showlegend true
1159
1208
  var toShowLegend = input.data.reduce(function (acc, series) {
1160
- return acc || series.showlegend === true;
1209
+ return (acc || series.showlegend === true || series.showlegend === undefined);
1161
1210
  }, false);
1162
1211
  if (toShowLegend) {
1163
1212
  input.data.forEach(function (series, index) {
1164
- var _a, _b, _c, _d, _e;
1165
- var name = series.legendgroup;
1166
- var color = ((_a = series.line) === null || _a === void 0 ? void 0 : _a.color) || ((_b = series.marker) === null || _b === void 0 ? void 0 : _b.color);
1167
- var legendShape = getLegendShape(series);
1168
- var resolvedColor = (0, PlotlyColorAdapter_1.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);
1169
- if (name !== undefined && allupLegends.some(function (group) { return group.title === name; }) === false) {
1170
- allupLegends.push({
1171
- title: name,
1172
- color: resolvedColor,
1173
- shape: legendShape,
1213
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
1214
+ if (traceInfo[index].type === 'donut') {
1215
+ var pieSeries = series;
1216
+ var colors_2 = (0, PlotlyColorAdapter_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);
1217
+ (_j = pieSeries.labels) === null || _j === void 0 ? void 0 : _j.forEach(function (label, labelIndex) {
1218
+ var legend = "".concat(label);
1219
+ // resolve color for each legend from the extracted colors
1220
+ var color = (0, PlotlyColorAdapter_1.resolveColor)(colors_2, labelIndex, legend, colorMap, isDarkTheme);
1221
+ if (legend !== '' && allupLegends.some(function (group) { return group.title === legend; }) === false) {
1222
+ allupLegends.push({
1223
+ title: legend,
1224
+ color: color,
1225
+ });
1226
+ }
1174
1227
  });
1175
1228
  }
1229
+ else if ((0, exports.isNonPlotType)(traceInfo[index].type) === false) {
1230
+ var plotSeries = series;
1231
+ var name_1 = plotSeries.legendgroup;
1232
+ var color = ((_k = plotSeries.line) === null || _k === void 0 ? void 0 : _k.color) || ((_l = plotSeries.marker) === null || _l === void 0 ? void 0 : _l.color);
1233
+ var legendShape = getLegendShape(plotSeries);
1234
+ var resolvedColor = (0, PlotlyColorAdapter_1.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);
1235
+ if (name_1 !== undefined && name_1 !== '' && allupLegends.some(function (group) { return group.title === name_1; }) === false) {
1236
+ allupLegends.push({
1237
+ title: name_1,
1238
+ color: resolvedColor,
1239
+ shape: legendShape,
1240
+ });
1241
+ }
1242
+ }
1176
1243
  });
1177
1244
  }
1178
1245
  return {
@@ -1235,153 +1302,163 @@ var getIndexFromKey = function (key, pattern) {
1235
1302
  var normalizedKey = key.replace(pattern, '') === '' ? '1' : key.replace(pattern, '');
1236
1303
  return parseInt(normalizedKey, 10) - 1;
1237
1304
  };
1238
- var getGridProperties = function (layout, isMultiPlot) {
1305
+ var isNonPlotType = function (chartType) {
1306
+ return ['donut', 'sankey', 'pie'].includes(chartType);
1307
+ };
1308
+ exports.isNonPlotType = isNonPlotType;
1309
+ var getGridProperties = function (schema, isMultiPlot, validTracesInfo) {
1239
1310
  var _a;
1240
- var gridX = [];
1241
- var gridY = [];
1311
+ var domainX = [];
1312
+ var domainY = [];
1313
+ var cartesianDomains = 0;
1242
1314
  var annotations = {};
1243
1315
  var templateRows = '1fr';
1244
1316
  var templateColumns = '1fr';
1245
1317
  var gridLayout = {};
1246
- if (layout === undefined || layout === null || Object.keys(layout).length === 0) {
1247
- return { templateRows: templateRows, templateColumns: templateColumns, layout: gridLayout };
1248
- }
1249
- if (!layout.xaxis || !layout.yaxis) {
1250
- return { templateRows: templateRows, templateColumns: templateColumns, layout: gridLayout };
1251
- }
1252
1318
  if (!isMultiPlot) {
1253
1319
  return { templateRows: templateRows, templateColumns: templateColumns, layout: gridLayout };
1254
1320
  }
1255
- Object.keys(layout).forEach(function (key) {
1256
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1257
- if (key.startsWith('xaxis')) {
1258
- var index = getIndexFromKey(key, 'xaxis');
1259
- var anchor = (_b = (_a = layout[key]) === null || _a === void 0 ? void 0 : _a.anchor) !== null && _b !== void 0 ? _b : 'y';
1260
- var anchorIndex = getIndexFromKey(anchor, 'y');
1261
- if (index !== anchorIndex) {
1262
- throw new Error("Invalid layout: xaxis ".concat(index + 1, " anchor should be y").concat(anchorIndex + 1));
1321
+ var layout = schema === null || schema === void 0 ? void 0 : schema.layout;
1322
+ if (layout !== undefined && layout !== null && Object.keys(layout).length > 0) {
1323
+ Object.keys(layout !== null && layout !== void 0 ? layout : {}).forEach(function (key) {
1324
+ var _a, _b, _c, _d, _e;
1325
+ if (key.startsWith('xaxis')) {
1326
+ var index = getIndexFromKey(key, 'xaxis');
1327
+ var anchor = (_b = (_a = layout[key]) === null || _a === void 0 ? void 0 : _a.anchor) !== null && _b !== void 0 ? _b : 'y';
1328
+ var anchorIndex = getIndexFromKey(anchor, 'y');
1329
+ if (index !== anchorIndex) {
1330
+ throw new Error("Invalid layout: xaxis ".concat(index + 1, " anchor should be y").concat(anchorIndex + 1));
1331
+ }
1332
+ var xAxisLayout = layout[key];
1333
+ var domainXInfo = {
1334
+ start: (xAxisLayout === null || xAxisLayout === void 0 ? void 0 : xAxisLayout.domain) ? xAxisLayout.domain[0] : 0,
1335
+ end: (xAxisLayout === null || xAxisLayout === void 0 ? void 0 : xAxisLayout.domain) ? xAxisLayout.domain[1] : 1,
1336
+ };
1337
+ domainX.push(domainXInfo);
1263
1338
  }
1264
- gridX[index] = (_d = (_c = layout[key]) === null || _c === void 0 ? void 0 : _c.domain) !== null && _d !== void 0 ? _d : [];
1265
- }
1266
- else if (key.startsWith('yaxis')) {
1267
- var index = getIndexFromKey(key, 'yaxis');
1268
- var anchor = (_f = (_e = layout[key]) === null || _e === void 0 ? void 0 : _e.anchor) !== null && _f !== void 0 ? _f : 'x';
1269
- var anchorIndex = getIndexFromKey(anchor, 'x');
1270
- if (index !== anchorIndex) {
1271
- if ((index === 1 && anchorIndex === 0) || ((_g = layout.yaxis2) === null || _g === void 0 ? void 0 : _g.side) === 'right') {
1272
- // Special case for secondary y axis where yaxis2 can anchor to x1
1273
- return { templateRows: templateRows, templateColumns: templateColumns };
1339
+ else if (key.startsWith('yaxis')) {
1340
+ var index = getIndexFromKey(key, 'yaxis');
1341
+ var anchor = (_d = (_c = layout[key]) === null || _c === void 0 ? void 0 : _c.anchor) !== null && _d !== void 0 ? _d : 'x';
1342
+ var anchorIndex = getIndexFromKey(anchor, 'x');
1343
+ if (index !== anchorIndex) {
1344
+ if ((index === 1 && anchorIndex === 0) || ((_e = layout.yaxis2) === null || _e === void 0 ? void 0 : _e.side) === 'right') {
1345
+ // Special case for secondary y axis where yaxis2 can anchor to x1
1346
+ return { templateRows: templateRows, templateColumns: templateColumns };
1347
+ }
1348
+ throw new Error("Invalid layout: yaxis ".concat(index + 1, " anchor should be x").concat(anchorIndex + 1));
1274
1349
  }
1275
- throw new Error("Invalid layout: yaxis ".concat(index + 1, " anchor should be x").concat(anchorIndex + 1));
1350
+ var yAxisLayout = layout[key];
1351
+ var domainYInfo = {
1352
+ start: (yAxisLayout === null || yAxisLayout === void 0 ? void 0 : yAxisLayout.domain) ? yAxisLayout.domain[0] : 0,
1353
+ end: (yAxisLayout === null || yAxisLayout === void 0 ? void 0 : yAxisLayout.domain) ? yAxisLayout.domain[1] : 1,
1354
+ };
1355
+ domainY.push(domainYInfo);
1276
1356
  }
1277
- gridY[index] = (_j = (_h = layout[key]) === null || _h === void 0 ? void 0 : _h.domain) !== null && _j !== void 0 ? _j : [];
1278
- }
1279
- });
1280
- (_a = layout.annotations) === null || _a === void 0 ? void 0 : _a.forEach(function (annotation) {
1281
- var xMatches = gridX.flatMap(function (interval, idx) {
1282
- return (annotation === null || annotation === void 0 ? void 0 : annotation.x) >= interval[0] && (annotation === null || annotation === void 0 ? void 0 : annotation.x) <= interval[1] ? [idx] : [];
1283
1357
  });
1284
- var yMatch = gridY.findIndex(function (interval, yIndex) {
1285
- return xMatches.includes(yIndex) &&
1286
- (annotation === null || annotation === void 0 ? void 0 : annotation.y) >= interval[0] &&
1287
- (annotation === null || annotation === void 0 ? void 0 : annotation.y) <= interval[1];
1288
- });
1289
- if (yMatch !== -1) {
1290
- if (annotations[yMatch] === undefined) {
1291
- annotations[yMatch] = {};
1292
- }
1293
- if ((annotation === null || annotation === void 0 ? void 0 : annotation.textangle) === 90) {
1294
- annotations[yMatch].yAnnotation = annotation.text;
1295
- }
1296
- else {
1297
- annotations[yMatch].xAnnotation = annotation.text;
1298
- }
1358
+ }
1359
+ cartesianDomains = domainX.length; // Assuming that the number of x and y axes is the same
1360
+ validTracesInfo.forEach(function (trace, index) {
1361
+ var _a, _b, _c, _d, _e;
1362
+ if ((0, exports.isNonPlotType)(trace.type)) {
1363
+ var series = (_a = schema === null || schema === void 0 ? void 0 : schema.data) === null || _a === void 0 ? void 0 : _a[index];
1364
+ var domainXInfo = {
1365
+ start: ((_b = series.domain) === null || _b === void 0 ? void 0 : _b.x) ? series.domain.x[0] : 0,
1366
+ end: ((_c = series.domain) === null || _c === void 0 ? void 0 : _c.x) ? series.domain.x[1] : 1,
1367
+ };
1368
+ var domainYInfo = {
1369
+ start: ((_d = series.domain) === null || _d === void 0 ? void 0 : _d.y) ? series.domain.y[0] : 0,
1370
+ end: ((_e = series.domain) === null || _e === void 0 ? void 0 : _e.y) ? series.domain.y[1] : 1,
1371
+ };
1372
+ domainX.push(domainXInfo);
1373
+ domainY.push(domainYInfo);
1299
1374
  }
1300
1375
  });
1301
- if (gridX.length > 0) {
1376
+ if (layout !== undefined && layout !== null && Object.keys(layout).length > 0) {
1377
+ (_a = layout.annotations) === null || _a === void 0 ? void 0 : _a.forEach(function (annotation) {
1378
+ var xMatches = domainX.flatMap(function (interval, idx) {
1379
+ return (annotation === null || annotation === void 0 ? void 0 : annotation.x) >= interval.start && (annotation === null || annotation === void 0 ? void 0 : annotation.x) <= interval.end ? [idx] : [];
1380
+ });
1381
+ var yMatch = domainY.findIndex(function (interval, yIndex) {
1382
+ return xMatches.includes(yIndex) &&
1383
+ (annotation === null || annotation === void 0 ? void 0 : annotation.y) >= interval.start &&
1384
+ (annotation === null || annotation === void 0 ? void 0 : annotation.y) <= interval.end;
1385
+ });
1386
+ if (yMatch !== -1) {
1387
+ if (annotations[yMatch] === undefined) {
1388
+ annotations[yMatch] = {};
1389
+ }
1390
+ if ((annotation === null || annotation === void 0 ? void 0 : annotation.textangle) === 90) {
1391
+ annotations[yMatch].yAnnotation = annotation.text;
1392
+ }
1393
+ else {
1394
+ annotations[yMatch].xAnnotation = annotation.text;
1395
+ }
1396
+ }
1397
+ });
1398
+ }
1399
+ if (domainX.length > 0) {
1302
1400
  var uniqueXIntervals_1 = new Map();
1303
- gridX.forEach(function (interval) {
1304
- var key = "".concat(interval[0], "-").concat(interval[1]);
1401
+ domainX.forEach(function (interval) {
1402
+ var key = "".concat(interval.start, "-").concat(interval.end);
1305
1403
  if (!uniqueXIntervals_1.has(key)) {
1306
1404
  uniqueXIntervals_1.set(key, interval);
1307
1405
  }
1308
1406
  });
1309
- var minXInterval_1 = Math.min.apply(Math, Array.from(uniqueXIntervals_1.values()).map(function (interval) { return interval[1] - interval[0]; }));
1310
- templateColumns = Array.from(uniqueXIntervals_1.values())
1311
- .map(function (interval) { return "".concat((interval[1] - interval[0]) / minXInterval_1, "fr"); })
1312
- .join(' ');
1313
- var columnNumber_1 = 1;
1314
- var lastIntervalEnd_1 = 0;
1315
- gridX.forEach(function (interval, index) {
1316
- if (interval.length === 0) {
1317
- return;
1318
- }
1319
- var cellName = "x".concat(index === 0 ? '' : index + 1);
1407
+ var sortedXStart_1 = Array.from(uniqueXIntervals_1.values())
1408
+ .map(function (interval) { return interval.start; })
1409
+ .sort();
1410
+ templateColumns = "repeat(".concat(sortedXStart_1.length, ", 1fr)");
1411
+ domainX.forEach(function (interval, index) {
1412
+ var cellName = index >= cartesianDomains
1413
+ ? "".concat(exports.NON_PLOT_KEY_PREFIX).concat(index - cartesianDomains + 1)
1414
+ : "x".concat(index === 0 ? '' : index + 1);
1415
+ var columnIndex = sortedXStart_1.findIndex(function (start) { return start === interval.start; });
1416
+ var columnNumber = columnIndex + 1; // Column numbers are 1-based
1320
1417
  var annotationProps = annotations[index];
1321
1418
  var xAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.xAnnotation;
1322
- if (interval[0] < lastIntervalEnd_1) {
1323
- columnNumber_1 = 1;
1324
- }
1325
- lastIntervalEnd_1 = interval[1];
1326
1419
  var row = {
1327
1420
  row: -1,
1328
- column: columnNumber_1,
1421
+ column: columnNumber,
1329
1422
  xAnnotation: xAnnotation,
1423
+ xDomain: interval,
1424
+ yDomain: { start: 0, end: 1 }, // Default yDomain for x-axis
1330
1425
  };
1331
1426
  gridLayout[cellName] = row;
1332
- columnNumber_1 += 1;
1333
1427
  });
1334
1428
  }
1335
- var numColumns = Math.max.apply(Math, Object.values(gridLayout).map(function (cell) { var _a; return (_a = cell.column) !== null && _a !== void 0 ? _a : 0; }));
1336
- var columnFill = {};
1337
- for (var i = 1; i <= numColumns; i++) {
1338
- columnFill[i] = { row: 1, fillDomain: 0 };
1339
- }
1340
- if (gridY.length > 0) {
1429
+ if (domainY.length > 0) {
1341
1430
  var uniqueYIntervals_1 = new Map();
1342
- gridY.forEach(function (interval) {
1343
- var key = "".concat(interval[0], "-").concat(interval[1]);
1431
+ domainY.forEach(function (interval) {
1432
+ var key = "".concat(interval.start, "-").concat(interval.end);
1344
1433
  if (!uniqueYIntervals_1.has(key)) {
1345
1434
  uniqueYIntervals_1.set(key, interval);
1346
1435
  }
1347
1436
  });
1348
- var minYInterval_1 = Math.min.apply(Math, Array.from(uniqueYIntervals_1.values()).map(function (interval) { return interval[1] - interval[0]; }));
1349
- templateRows = Array.from(uniqueYIntervals_1.values())
1350
- .map(function (interval) { return "".concat((interval[1] - interval[0]) / minYInterval_1, "fr"); })
1351
- .join(' ');
1352
- gridY.forEach(function (interval, index) {
1353
- if (interval.length === 0) {
1354
- return;
1355
- }
1356
- var cellName = "x".concat(index === 0 ? '' : index + 1);
1437
+ var sortedYStart_1 = Array.from(uniqueYIntervals_1.values())
1438
+ .map(function (interval) { return interval.start; })
1439
+ .sort();
1440
+ var numberOfRows_1 = sortedYStart_1.length;
1441
+ templateRows = "repeat(".concat(numberOfRows_1, ", 1fr)");
1442
+ domainY.forEach(function (interval, index) {
1443
+ var cellName = index >= cartesianDomains
1444
+ ? "".concat(exports.NON_PLOT_KEY_PREFIX).concat(index - cartesianDomains + 1)
1445
+ : "x".concat(index === 0 ? '' : index + 1);
1446
+ var rowIndex = sortedYStart_1.findIndex(function (start) { return start === interval.start; });
1447
+ var rowNumber = numberOfRows_1 - rowIndex; // Rows are 1-based and we need to reverse the order for CSS grid
1357
1448
  var annotationProps = annotations[index];
1358
1449
  var yAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.yAnnotation;
1359
1450
  var cell = gridLayout[cellName];
1360
1451
  if (cell !== undefined) {
1361
- cell.row = columnFill[cell.column].row;
1452
+ cell.row = rowNumber;
1362
1453
  cell.yAnnotation = yAnnotation;
1454
+ cell.yDomain = interval;
1363
1455
  }
1364
- columnFill[cell.column].fillDomain = interval[1];
1365
- columnFill[cell.column].row += 1;
1366
1456
  });
1367
1457
  }
1368
- // reverse the order of rows in grid layout from bottom-top to top-bottom as required by CSS grid
1369
- var reversedGridLayout = {};
1370
- // find the maximum row number
1371
- var maxRowNumber = Math.max.apply(Math, Object.values(gridLayout).map(function (cell) { var _a; return (_a = cell.row) !== null && _a !== void 0 ? _a : 0; }));
1372
- // iterate over the gridLayout and reverse the row numbers
1373
- Object.keys(gridLayout).forEach(function (key) {
1374
- var cell = gridLayout[key];
1375
- if (cell.row !== undefined) {
1376
- // reverse the row number
1377
- cell.row = maxRowNumber - cell.row + 1;
1378
- }
1379
- reversedGridLayout[key] = cell;
1380
- });
1381
1458
  return {
1382
1459
  templateRows: templateRows,
1383
1460
  templateColumns: templateColumns,
1384
- layout: reversedGridLayout,
1461
+ layout: gridLayout,
1385
1462
  };
1386
1463
  };
1387
1464
  exports.getGridProperties = getGridProperties;