@fluentui/react-charting 5.24.3 → 5.24.5

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 (170) hide show
  1. package/CHANGELOG.json +85 -1
  2. package/CHANGELOG.md +29 -2
  3. package/config/tests.js +0 -12
  4. package/dist/react-charting.d.ts +38 -1
  5. package/dist/react-charting.js +1 -1
  6. package/dist/react-charting.min.js +1 -1
  7. package/etc/react-charting.api.md +8 -1
  8. package/lib/components/AreaChart/AreaChart.base.d.ts +1 -0
  9. package/lib/components/AreaChart/AreaChart.base.js +4 -1
  10. package/lib/components/AreaChart/AreaChart.base.js.map +1 -1
  11. package/lib/components/CommonComponents/CartesianChart.base.js +14 -13
  12. package/lib/components/CommonComponents/CartesianChart.base.js.map +1 -1
  13. package/lib/components/CommonComponents/CartesianChart.styles.js +41 -37
  14. package/lib/components/CommonComponents/CartesianChart.styles.js.map +1 -1
  15. package/lib/components/CommonComponents/CartesianChart.types.d.ts +12 -2
  16. package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
  17. package/lib/components/DeclarativeChart/DeclarativeChart.js +38 -16
  18. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  19. package/lib/components/DeclarativeChart/PlotlyColorAdapter.d.ts +2 -1
  20. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +9 -1
  21. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
  22. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +13 -3
  23. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +276 -199
  24. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  25. package/lib/components/DonutChart/DonutChart.base.js +1 -0
  26. package/lib/components/DonutChart/DonutChart.base.js.map +1 -1
  27. package/lib/components/DonutChart/DonutChart.styles.js +18 -0
  28. package/lib/components/DonutChart/DonutChart.styles.js.map +1 -1
  29. package/lib/components/DonutChart/DonutChart.types.d.ts +4 -0
  30. package/lib/components/DonutChart/DonutChart.types.js.map +1 -1
  31. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.d.ts +2 -0
  32. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +25 -4
  33. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
  34. package/lib/components/HeatMapChart/HeatMapChart.base.d.ts +7 -0
  35. package/lib/components/HeatMapChart/HeatMapChart.base.js +95 -37
  36. package/lib/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
  37. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.d.ts +3 -0
  38. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +24 -3
  39. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
  40. package/lib/components/ScatterChart/ScatterChart.base.js +84 -55
  41. package/lib/components/ScatterChart/ScatterChart.base.js.map +1 -1
  42. package/lib/components/ScatterChart/ScatterChart.styles.js +12 -0
  43. package/lib/components/ScatterChart/ScatterChart.styles.js.map +1 -1
  44. package/lib/components/ScatterChart/ScatterChart.types.d.ts +5 -0
  45. package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -1
  46. package/lib/components/VerticalBarChart/VerticalBarChart.base.d.ts +2 -0
  47. package/lib/components/VerticalBarChart/VerticalBarChart.base.js +30 -7
  48. package/lib/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
  49. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.d.ts +3 -0
  50. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +51 -32
  51. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
  52. package/lib/index.d.ts +1 -1
  53. package/lib/index.js.map +1 -1
  54. package/lib/types/IDataPoint.d.ts +18 -0
  55. package/lib/types/IDataPoint.js.map +1 -1
  56. package/lib/utilities/SVGTooltipText.js +3 -3
  57. package/lib/utilities/SVGTooltipText.js.map +1 -1
  58. package/lib/utilities/utilities.d.ts +6 -3
  59. package/lib/utilities/utilities.js +58 -29
  60. package/lib/utilities/utilities.js.map +1 -1
  61. package/lib-amd/components/AreaChart/AreaChart.base.d.ts +1 -0
  62. package/lib-amd/components/AreaChart/AreaChart.base.js +4 -1
  63. package/lib-amd/components/AreaChart/AreaChart.base.js.map +1 -1
  64. package/lib-amd/components/CommonComponents/CartesianChart.base.js +14 -13
  65. package/lib-amd/components/CommonComponents/CartesianChart.base.js.map +1 -1
  66. package/lib-amd/components/CommonComponents/CartesianChart.styles.js +41 -37
  67. package/lib-amd/components/CommonComponents/CartesianChart.styles.js.map +1 -1
  68. package/lib-amd/components/CommonComponents/CartesianChart.types.d.ts +12 -2
  69. package/lib-amd/components/CommonComponents/CartesianChart.types.js.map +1 -1
  70. package/lib-amd/components/DeclarativeChart/DeclarativeChart.js +37 -15
  71. package/lib-amd/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  72. package/lib-amd/components/DeclarativeChart/PlotlyColorAdapter.d.ts +2 -1
  73. package/lib-amd/components/DeclarativeChart/PlotlyColorAdapter.js +11 -2
  74. package/lib-amd/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
  75. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +13 -3
  76. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +276 -199
  77. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  78. package/lib-amd/components/DonutChart/DonutChart.base.js +1 -0
  79. package/lib-amd/components/DonutChart/DonutChart.base.js.map +1 -1
  80. package/lib-amd/components/DonutChart/DonutChart.styles.js +17 -1
  81. package/lib-amd/components/DonutChart/DonutChart.styles.js.map +1 -1
  82. package/lib-amd/components/DonutChart/DonutChart.types.d.ts +4 -0
  83. package/lib-amd/components/DonutChart/DonutChart.types.js.map +1 -1
  84. package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.d.ts +2 -0
  85. package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +24 -3
  86. package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
  87. package/lib-amd/components/HeatMapChart/HeatMapChart.base.d.ts +7 -0
  88. package/lib-amd/components/HeatMapChart/HeatMapChart.base.js +94 -36
  89. package/lib-amd/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
  90. package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.d.ts +3 -0
  91. package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +23 -2
  92. package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
  93. package/lib-amd/components/ScatterChart/ScatterChart.base.js +83 -54
  94. package/lib-amd/components/ScatterChart/ScatterChart.base.js.map +1 -1
  95. package/lib-amd/components/ScatterChart/ScatterChart.styles.js +12 -1
  96. package/lib-amd/components/ScatterChart/ScatterChart.styles.js.map +1 -1
  97. package/lib-amd/components/ScatterChart/ScatterChart.types.d.ts +5 -0
  98. package/lib-amd/components/ScatterChart/ScatterChart.types.js.map +1 -1
  99. package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.d.ts +2 -0
  100. package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js +29 -6
  101. package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
  102. package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.d.ts +3 -0
  103. package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +50 -31
  104. package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
  105. package/lib-amd/index.d.ts +1 -1
  106. package/lib-amd/index.js.map +1 -1
  107. package/lib-amd/types/IDataPoint.d.ts +18 -0
  108. package/lib-amd/types/IDataPoint.js.map +1 -1
  109. package/lib-amd/utilities/SVGTooltipText.js +3 -3
  110. package/lib-amd/utilities/SVGTooltipText.js.map +1 -1
  111. package/lib-amd/utilities/utilities.d.ts +6 -3
  112. package/lib-amd/utilities/utilities.js +59 -30
  113. package/lib-amd/utilities/utilities.js.map +1 -1
  114. package/lib-commonjs/components/AreaChart/AreaChart.base.d.ts +1 -0
  115. package/lib-commonjs/components/AreaChart/AreaChart.base.js +4 -1
  116. package/lib-commonjs/components/AreaChart/AreaChart.base.js.map +1 -1
  117. package/lib-commonjs/components/CommonComponents/CartesianChart.base.js +14 -13
  118. package/lib-commonjs/components/CommonComponents/CartesianChart.base.js.map +1 -1
  119. package/lib-commonjs/components/CommonComponents/CartesianChart.styles.js +41 -37
  120. package/lib-commonjs/components/CommonComponents/CartesianChart.styles.js.map +1 -1
  121. package/lib-commonjs/components/CommonComponents/CartesianChart.types.d.ts +12 -2
  122. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
  123. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +37 -15
  124. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  125. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.d.ts +2 -1
  126. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +11 -2
  127. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
  128. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +13 -3
  129. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +276 -198
  130. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  131. package/lib-commonjs/components/DonutChart/DonutChart.base.js +1 -0
  132. package/lib-commonjs/components/DonutChart/DonutChart.base.js.map +1 -1
  133. package/lib-commonjs/components/DonutChart/DonutChart.styles.js +18 -0
  134. package/lib-commonjs/components/DonutChart/DonutChart.styles.js.map +1 -1
  135. package/lib-commonjs/components/DonutChart/DonutChart.types.d.ts +4 -0
  136. package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -1
  137. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.d.ts +2 -0
  138. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +24 -3
  139. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
  140. package/lib-commonjs/components/HeatMapChart/HeatMapChart.base.d.ts +7 -0
  141. package/lib-commonjs/components/HeatMapChart/HeatMapChart.base.js +94 -36
  142. package/lib-commonjs/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
  143. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.d.ts +3 -0
  144. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +23 -2
  145. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
  146. package/lib-commonjs/components/ScatterChart/ScatterChart.base.js +83 -54
  147. package/lib-commonjs/components/ScatterChart/ScatterChart.base.js.map +1 -1
  148. package/lib-commonjs/components/ScatterChart/ScatterChart.styles.js +12 -0
  149. package/lib-commonjs/components/ScatterChart/ScatterChart.styles.js.map +1 -1
  150. package/lib-commonjs/components/ScatterChart/ScatterChart.types.d.ts +5 -0
  151. package/lib-commonjs/components/ScatterChart/ScatterChart.types.js.map +1 -1
  152. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.d.ts +2 -0
  153. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js +29 -6
  154. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
  155. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.d.ts +3 -0
  156. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +50 -31
  157. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
  158. package/lib-commonjs/index.d.ts +1 -1
  159. package/lib-commonjs/index.js.map +1 -1
  160. package/lib-commonjs/types/IDataPoint.d.ts +18 -0
  161. package/lib-commonjs/types/IDataPoint.js.map +1 -1
  162. package/lib-commonjs/utilities/SVGTooltipText.js +3 -3
  163. package/lib-commonjs/utilities/SVGTooltipText.js.map +1 -1
  164. package/lib-commonjs/utilities/utilities.d.ts +6 -3
  165. package/lib-commonjs/utilities/utilities.js +59 -30
  166. package/lib-commonjs/utilities/utilities.js.map +1 -1
  167. package/package.json +2 -2
  168. package/src/components/CommonComponents/CartesianChart.types.ts +20 -1
  169. package/src/components/DonutChart/DonutChart.types.ts +5 -0
  170. package/src/components/ScatterChart/ScatterChart.types.ts +7 -1
@@ -5,9 +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
- import { extractColor, resolveColor } from './PlotlyColorAdapter';
10
+ import { getOpacity, extractColor, resolveColor } from './PlotlyColorAdapter';
11
+ import { rgb } from 'd3-color';
12
+ export var NON_PLOT_KEY_PREFIX = 'nonplot_';
13
+ export var SINGLE_REPEAT = 'repeat(1, 1fr)';
11
14
  var dashOptions = {
12
15
  dot: {
13
16
  strokeDasharray: '1, 5',
@@ -55,6 +58,47 @@ function getTitles(layout) {
55
58
  };
56
59
  return titles;
57
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
+ };
58
102
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
59
103
  export var correctYearMonth = function (xValues) {
60
104
  var presentYear = new Date().getFullYear();
@@ -202,7 +246,7 @@ export var transformPlotlyJsonToDonutProps = function (input, isMultiPlot, color
202
246
  chartTitle: chartTitle,
203
247
  chartData: Object.values(mapLegendToDataPoint),
204
248
  },
205
- 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,
206
250
  width: (_q = input.layout) === null || _q === void 0 ? void 0 : _q.width,
207
251
  height: height,
208
252
  innerRadius: innerRadius,
@@ -219,6 +263,7 @@ export var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorM
219
263
  var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
220
264
  var _d = getLegendProps(input.data, input.layout, isMultiPlot), legends = _d.legends, hideLegend = _d.hideLegend;
221
265
  var colorScale = undefined;
266
+ var yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
222
267
  input.data.forEach(function (series, index1) {
223
268
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
224
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) &&
@@ -242,7 +287,7 @@ export var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorM
242
287
  var rangeXValues = series.x.slice(rangeStart, rangeEnd);
243
288
  var rangeYValues = series.y.slice(rangeStart, rangeEnd);
244
289
  rangeXValues.forEach(function (x, index2) {
245
- var _a, _b, _c, _d;
290
+ var _a, _b, _c, _d, _e, _f;
246
291
  if (!mapXToDataPoints[x]) {
247
292
  mapXToDataPoints[x] = {
248
293
  xAxisPoint: resolveXAxisPoint(x, isXYearCategory, isXString, isXDate, isXNumber),
@@ -257,12 +302,15 @@ export var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorM
257
302
  ? (_c = (_b = series.marker) === null || _b === void 0 ? void 0 : _b.color) === null || _c === void 0 ? void 0 : _c[index2 % ((_d = series.marker) === null || _d === void 0 ? void 0 : _d.color).length]
258
303
  : 0)
259
304
  : resolveColor(extractedBarColors, index2, legend, colorMap, isDarkTheme);
305
+ var opacity = getOpacity(series, index2);
260
306
  var yVal = rangeYValues[index2];
307
+ var yAxisCalloutData = getFormattedCalloutYData(yVal, yAxisTickFormat);
261
308
  if (series.type === 'bar') {
262
309
  mapXToDataPoints[x].chartData.push({
263
310
  legend: legend,
264
311
  data: yVal,
265
- color: color,
312
+ color: (_e = rgb(color).copy({ opacity: opacity }).formatHex8()) !== null && _e !== void 0 ? _e : color,
313
+ yAxisCalloutData: yAxisCalloutData,
266
314
  });
267
315
  if (typeof yVal === 'number') {
268
316
  yMaxValue = Math.max(yMaxValue, yVal);
@@ -276,9 +324,10 @@ export var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorM
276
324
  legend: legend + (validXYRanges.length > 1 ? ".".concat(rangeIdx + 1) : ''),
277
325
  legendShape: legendShape,
278
326
  y: yVal,
279
- color: lineColor,
327
+ color: (_f = rgb(lineColor).copy({ opacity: opacity }).formatHex8()) !== null && _f !== void 0 ? _f : color,
280
328
  lineOptions: __assign(__assign({}, (lineOptions !== null && lineOptions !== void 0 ? lineOptions : {})), { mode: series.mode }),
281
329
  useSecondaryYScale: usesSecondaryYScale(series, input.layout),
330
+ yAxisCalloutData: yAxisCalloutData,
282
331
  });
283
332
  if (!usesSecondaryYScale(series, input.layout) && typeof yVal === 'number') {
284
333
  yMaxValue = Math.max(yMaxValue, yVal);
@@ -288,8 +337,7 @@ export var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorM
288
337
  });
289
338
  });
290
339
  });
291
- var _e = getTitles(input.layout), chartTitle = _e.chartTitle, xAxisTitle = _e.xAxisTitle, yAxisTitle = _e.yAxisTitle;
292
- return __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 });
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);
293
341
  };
294
342
  var createColorScale = function (layout, series) {
295
343
  var _a, _b, _c, _d, _e, _f;
@@ -313,6 +361,7 @@ export var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorM
313
361
  var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, 0, 0);
314
362
  var _d = getLegendProps(input.data, input.layout, isMultiPlot), legends = _d.legends, hideLegend = _d.hideLegend;
315
363
  var colorScale = undefined;
364
+ var yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
316
365
  input.data.forEach(function (series, index1) {
317
366
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
318
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) &&
@@ -324,7 +373,7 @@ export var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorM
324
373
  // extract colors for each series only once
325
374
  var extractedColors = extractColor((_k = (_j = (_h = input.layout) === null || _h === void 0 ? void 0 : _h.template) === null || _j === void 0 ? void 0 : _j.layout) === null || _k === void 0 ? void 0 : _k.colorway, colorwayType, (_l = series.marker) === null || _l === void 0 ? void 0 : _l.color, colorMap, isDarkTheme);
326
375
  (_m = series.x) === null || _m === void 0 ? void 0 : _m.forEach(function (x, xIndex) {
327
- var _a, _b, _c, _d, _e;
376
+ var _a, _b, _c, _d, _e, _f;
328
377
  if (isInvalidValue(x) || isInvalidValue((_a = series.y) === null || _a === void 0 ? void 0 : _a[xIndex])) {
329
378
  return;
330
379
  }
@@ -338,20 +387,22 @@ export var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorM
338
387
  ? colorScale(isArrayOrTypedArray((_b = series.marker) === null || _b === void 0 ? void 0 : _b.color)
339
388
  ? (_d = (_c = series.marker) === null || _c === void 0 ? void 0 : _c.color) === null || _d === void 0 ? void 0 : _d[xIndex % ((_e = series.marker) === null || _e === void 0 ? void 0 : _e.color).length]
340
389
  : 0)
341
- : resolveColor(extractedColors, index1, legend, colorMap, isDarkTheme);
390
+ : resolveColor(extractedColors, xIndex, legend, colorMap, isDarkTheme);
391
+ var opacity = getOpacity(series, xIndex);
392
+ var yVal = series.y[xIndex];
342
393
  mapXToDataPoints[x].series.push({
343
394
  key: legend,
344
- data: series.y[xIndex],
395
+ data: yVal,
345
396
  xAxisCalloutData: x,
346
- color: color,
397
+ color: (_f = rgb(color).copy({ opacity: opacity }).formatHex8()) !== null && _f !== void 0 ? _f : color,
347
398
  legend: legend,
348
399
  useSecondaryYScale: usesSecondaryYScale(series, input.layout),
400
+ yAxisCalloutData: getFormattedCalloutYData(yVal, yAxisTickFormat),
349
401
  });
350
402
  }
351
403
  });
352
404
  });
353
- var _e = getTitles(input.layout), chartTitle = _e.chartTitle, xAxisTitle = _e.xAxisTitle, yAxisTitle = _e.yAxisTitle;
354
- return __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 });
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);
355
406
  };
356
407
  export var transformPlotlyJsonToVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
357
408
  var _a, _b, _c;
@@ -399,7 +450,7 @@ export var transformPlotlyJsonToVBCProps = function (input, isMultiPlot, colorMa
399
450
  return yVal;
400
451
  });
401
452
  xBins.forEach(function (bin, index) {
402
- var _a, _b, _c, _d;
453
+ var _a, _b, _c, _d, _e;
403
454
  var legend = legends[seriesIdx];
404
455
  // resolve color for each legend's bars from the colorscale or extracted colors
405
456
  var color = colorScale
@@ -407,27 +458,14 @@ export var transformPlotlyJsonToVBCProps = function (input, isMultiPlot, colorMa
407
458
  ? (_c = (_b = series.marker) === null || _b === void 0 ? void 0 : _b.color) === null || _c === void 0 ? void 0 : _c[index % ((_d = series.marker) === null || _d === void 0 ? void 0 : _d.color).length]
408
459
  : 0)
409
460
  : resolveColor(extractedColors, index, legend, colorMap, isDarkTheme);
461
+ var opacity = getOpacity(series, index);
410
462
  var yVal = calculateHistNorm(series.histnorm, y[index], total, isXString ? bin.length : getBinSize(bin));
411
- vbcData.push(__assign({ x: isXString ? bin.join(', ') : getBinCenter(bin), y: yVal, legend: legend, color: color }, (isXString
463
+ vbcData.push(__assign({ x: isXString ? bin.join(', ') : getBinCenter(bin), y: yVal, legend: legend, color: (_e = rgb(color).copy({ opacity: opacity }).formatHex8()) !== null && _e !== void 0 ? _e : color }, (isXString
412
464
  ? {}
413
465
  : { xAxisCalloutData: "[".concat(bin.x0, " - ").concat(bin.x1, ")") })));
414
466
  });
415
467
  });
416
- var _e = getTitles(input.layout), chartTitle = _e.chartTitle, xAxisTitle = _e.xAxisTitle, yAxisTitle = _e.yAxisTitle;
417
- return {
418
- data: vbcData,
419
- width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width,
420
- height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350,
421
- supportNegativeData: true,
422
- chartTitle: chartTitle,
423
- xAxisTitle: xAxisTitle,
424
- yAxisTitle: yAxisTitle,
425
- mode: 'histogram',
426
- hideTickOverlap: true,
427
- maxBarWidth: 50,
428
- hideLegend: hideLegend,
429
- roundCorners: true,
430
- };
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));
431
469
  };
432
470
  export var transformPlotlyJsonToAreaChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
433
471
  return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'area', colorMap, colorwayType, isDarkTheme);
@@ -439,8 +477,9 @@ export var transformPlotlyJsonToScatterChartProps = function (input, isMultiPlot
439
477
  return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'scatter', colorMap, colorwayType, isDarkTheme);
440
478
  };
441
479
  var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme) {
442
- var _a, _b, _c, _d, _e, _f, _g;
480
+ var _a, _b, _c, _d;
443
481
  var isScatterMarkers = [
482
+ 'markers',
444
483
  'text+markers',
445
484
  'markers+text',
446
485
  'lines+markers',
@@ -451,7 +490,8 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
451
490
  var isScatterChart = chartType === 'scatter';
452
491
  var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
453
492
  var mode = 'tonexty';
454
- 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);
455
495
  var chartData = input.data
456
496
  .map(function (series, index) {
457
497
  var _a, _b, _c, _d, _e, _f, _g;
@@ -470,12 +510,13 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
470
510
  var legend = legends[index];
471
511
  // resolve color for each legend's lines from the extracted colors
472
512
  var seriesColor = resolveColor(extractedColors, index, legend, colorMap, isDarkTheme);
513
+ var seriesOpacity = getOpacity(series, index);
473
514
  mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
474
515
  var lineOptions = getLineOptions(series.line);
475
516
  var legendShape = getLegendShape(series);
476
517
  var validXYRanges = getValidXYRanges(series);
477
518
  return validXYRanges.map(function (_a, rangeIdx) {
478
- var _b;
519
+ var _b, _c;
479
520
  var rangeStart = _a[0], rangeEnd = _a[1];
480
521
  var rangeXValues = xValues.slice(rangeStart, rangeEnd);
481
522
  var rangeYValues = series.y.slice(rangeStart, rangeEnd);
@@ -488,35 +529,38 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
488
529
  legendShape: legendShape,
489
530
  data: rangeXValues.map(function (x, i) {
490
531
  var _a, _b;
491
- 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)
492
533
  ? { markerSize: markerSizes[i] }
493
534
  : typeof ((_b = series.marker) === null || _b === void 0 ? void 0 : _b.size) === 'number'
494
535
  ? { markerSize: series.marker.size }
495
- : {})), (textValues ? { text: textValues[i] } : {})));
536
+ : {})), (textValues ? { text: textValues[i] } : {})), { yAxisCalloutData: getFormattedCalloutYData(rangeYValues[i], yAxisTickFormat) }));
496
537
  }),
497
- color: seriesColor,
538
+ color: (_c = rgb(seriesColor).copy({ opacity: seriesOpacity }).formatHex8()) !== null && _c !== void 0 ? _c : seriesColor,
498
539
  lineOptions: __assign(__assign({}, (lineOptions !== null && lineOptions !== void 0 ? lineOptions : {})), { mode: series.mode }),
499
540
  useSecondaryYScale: usesSecondaryYScale(series, input.layout),
500
541
  };
501
542
  });
502
543
  })
503
544
  .flat();
504
- var yMinMaxValues = findNumericMinMaxOfY(chartData);
505
- 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
+ }
506
551
  var numDataPoints = chartData.reduce(function (total, lineChartPoints) { return total + lineChartPoints.data.length; }, 0);
507
552
  var chartProps = {
508
- chartTitle: chartTitle,
509
553
  lineChartData: chartData,
510
554
  };
511
555
  var scatterChartProps = {
512
- chartTitle: chartTitle,
513
556
  scatterChartData: chartData,
514
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);
515
559
  if (isAreaChart) {
516
- 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);
517
561
  }
518
562
  else {
519
- 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);
520
564
  }
521
565
  };
522
566
  export var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
@@ -537,7 +581,7 @@ export var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, is
537
581
  var legend = legends[index];
538
582
  return series.y
539
583
  .map(function (yValue, i) {
540
- var _a, _b, _c, _d, _e;
584
+ var _a, _b, _c, _d, _e, _f;
541
585
  if (isInvalidValue((_a = series.x) === null || _a === void 0 ? void 0 : _a[i]) || isInvalidValue(yValue)) {
542
586
  return null;
543
587
  }
@@ -547,19 +591,17 @@ export var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, is
547
591
  ? (_d = (_c = series.marker) === null || _c === void 0 ? void 0 : _c.color) === null || _d === void 0 ? void 0 : _d[i % ((_e = series.marker) === null || _e === void 0 ? void 0 : _e.color).length]
548
592
  : 0)
549
593
  : resolveColor(extractedColors, i, legend, colorMap, isDarkTheme);
594
+ var opacity = getOpacity(series, i);
550
595
  return {
551
596
  x: series.x[i],
552
597
  y: yValue,
553
598
  legend: legend,
554
- color: color,
599
+ color: (_f = rgb(color).copy({ opacity: opacity }).formatHex8()) !== null && _f !== void 0 ? _f : color,
555
600
  };
556
601
  })
557
602
  .filter(function (point) { return point !== null; });
558
603
  })
559
- .reverse()
560
- .flat()
561
- //reversing the order to invert the Y bars order as required by plotly.
562
- .reverse();
604
+ .flat();
563
605
  var chartHeight = (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.height) !== null && _b !== void 0 ? _b : 450;
564
606
  var margin = (_e = (_d = (_c = input.layout) === null || _c === void 0 ? void 0 : _c.margin) === null || _d === void 0 ? void 0 : _d.l) !== null && _e !== void 0 ? _e : 0;
565
607
  var padding = (_h = (_g = (_f = input.layout) === null || _f === void 0 ? void 0 : _f.margin) === null || _g === void 0 ? void 0 : _g.pad) !== null && _h !== void 0 ? _h : 0;
@@ -568,25 +610,9 @@ export var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, is
568
610
  var scalingFactor = 0.01;
569
611
  var gapFactor = 1 / (1 + scalingFactor * numberOfRows);
570
612
  var barHeight = availableHeight / (numberOfRows * (1 + gapFactor));
571
- var _t = getTitles(input.layout), chartTitle = _t.chartTitle, xAxisTitle = _t.xAxisTitle, yAxisTitle = _t.yAxisTitle;
572
- return {
573
- data: chartData,
574
- chartTitle: chartTitle,
575
- xAxisTitle: xAxisTitle,
576
- yAxisTitle: yAxisTitle,
577
- 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'
578
614
  ? (_m = (_l = input.layout) === null || _l === void 0 ? void 0 : _l.yaxis2) === null || _m === void 0 ? void 0 : _m.title
579
- : ((_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) || '',
580
- barHeight: barHeight,
581
- showYAxisLables: true,
582
- height: chartHeight,
583
- width: (_r = input.layout) === null || _r === void 0 ? void 0 : _r.width,
584
- hideTickOverlap: true,
585
- hideLegend: hideLegend,
586
- noOfCharsToTruncate: 20,
587
- showYAxisLablesTooltip: true,
588
- roundCorners: true,
589
- };
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));
590
616
  };
591
617
  export var transformPlotlyJsonToHeatmapProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
592
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;
@@ -700,23 +726,7 @@ export var transformPlotlyJsonToHeatmapProps = function (input, isMultiPlot, col
700
726
  var rangeValuesForColorScale = Array.isArray(colorscale)
701
727
  ? colorscale.map(function (arr) { return arr[1]; })
702
728
  : defaultRange;
703
- var _9 = getTitles(input.layout), chartTitle = _9.chartTitle, xAxisTitle = _9.xAxisTitle, yAxisTitle = _9.yAxisTitle;
704
- return {
705
- data: [heatmapData],
706
- domainValuesForColorScale: domainValuesForColorScale,
707
- rangeValuesForColorScale: rangeValuesForColorScale,
708
- hideLegend: true,
709
- showYAxisLables: true,
710
- chartTitle: chartTitle,
711
- xAxisTitle: xAxisTitle,
712
- yAxisTitle: yAxisTitle,
713
- sortOrder: 'none',
714
- width: (_6 = input.layout) === null || _6 === void 0 ? void 0 : _6.width,
715
- height: (_8 = (_7 = input.layout) === null || _7 === void 0 ? void 0 : _7.height) !== null && _8 !== void 0 ? _8 : 350,
716
- hideTickOverlap: true,
717
- noOfCharsToTruncate: 20,
718
- showYAxisLablesTooltip: true,
719
- };
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));
720
730
  };
721
731
  export var transformPlotlyJsonToSankeyProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
722
732
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
@@ -1172,26 +1182,44 @@ var getLegendShape = function (series) {
1172
1182
  }
1173
1183
  return 'default';
1174
1184
  };
1175
- export var getAllupLegendsProps = function (input, colorMap, colorwayType, isDarkTheme) {
1185
+ export var getAllupLegendsProps = function (input, colorMap, colorwayType, traceInfo, isDarkTheme) {
1176
1186
  var allupLegends = [];
1177
1187
  // reduce on showlegend boolean propperty. reduce should return true if at least one series has showlegend true
1178
1188
  var toShowLegend = input.data.reduce(function (acc, series) {
1179
- return acc || series.showlegend === true;
1189
+ return (acc || series.showlegend === true || series.showlegend === undefined);
1180
1190
  }, false);
1181
1191
  if (toShowLegend) {
1182
1192
  input.data.forEach(function (series, index) {
1183
- var _a, _b, _c, _d, _e;
1184
- var name = series.legendgroup;
1185
- var color = ((_a = series.line) === null || _a === void 0 ? void 0 : _a.color) || ((_b = series.marker) === null || _b === void 0 ? void 0 : _b.color);
1186
- var legendShape = getLegendShape(series);
1187
- 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);
1188
- if (name !== undefined && allupLegends.some(function (group) { return group.title === name; }) === false) {
1189
- allupLegends.push({
1190
- title: name,
1191
- color: resolvedColor,
1192
- 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
+ }
1193
1207
  });
1194
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
+ }
1195
1223
  });
1196
1224
  }
1197
1225
  return {
@@ -1251,153 +1279,202 @@ var getIndexFromKey = function (key, pattern) {
1251
1279
  var normalizedKey = key.replace(pattern, '') === '' ? '1' : key.replace(pattern, '');
1252
1280
  return parseInt(normalizedKey, 10) - 1;
1253
1281
  };
1254
- 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) {
1255
1286
  var _a;
1256
- var gridX = [];
1257
- var gridY = [];
1287
+ var domainX = [];
1288
+ var domainY = [];
1289
+ var cartesianDomains = 0;
1258
1290
  var annotations = {};
1259
1291
  var templateRows = '1fr';
1260
1292
  var templateColumns = '1fr';
1261
1293
  var gridLayout = {};
1262
- if (layout === undefined || layout === null || Object.keys(layout).length === 0) {
1263
- return { templateRows: templateRows, templateColumns: templateColumns, layout: gridLayout };
1264
- }
1265
- if (!layout.xaxis || !layout.yaxis) {
1266
- return { templateRows: templateRows, templateColumns: templateColumns, layout: gridLayout };
1267
- }
1268
1294
  if (!isMultiPlot) {
1269
1295
  return { templateRows: templateRows, templateColumns: templateColumns, layout: gridLayout };
1270
1296
  }
1271
- Object.keys(layout).forEach(function (key) {
1272
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1273
- if (key.startsWith('xaxis')) {
1274
- var index = getIndexFromKey(key, 'xaxis');
1275
- var anchor = (_b = (_a = layout[key]) === null || _a === void 0 ? void 0 : _a.anchor) !== null && _b !== void 0 ? _b : 'y';
1276
- var anchorIndex = getIndexFromKey(anchor, 'y');
1277
- if (index !== anchorIndex) {
1278
- 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);
1279
1314
  }
1280
- gridX[index] = (_d = (_c = layout[key]) === null || _c === void 0 ? void 0 : _c.domain) !== null && _d !== void 0 ? _d : [];
1281
- }
1282
- else if (key.startsWith('yaxis')) {
1283
- var index = getIndexFromKey(key, 'yaxis');
1284
- var anchor = (_f = (_e = layout[key]) === null || _e === void 0 ? void 0 : _e.anchor) !== null && _f !== void 0 ? _f : 'x';
1285
- var anchorIndex = getIndexFromKey(anchor, 'x');
1286
- if (index !== anchorIndex) {
1287
- if ((index === 1 && anchorIndex === 0) || ((_g = layout.yaxis2) === null || _g === void 0 ? void 0 : _g.side) === 'right') {
1288
- // Special case for secondary y axis where yaxis2 can anchor to x1
1289
- 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));
1290
1325
  }
1291
- 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);
1292
1332
  }
1293
- gridY[index] = (_j = (_h = layout[key]) === null || _h === void 0 ? void 0 : _h.domain) !== null && _j !== void 0 ? _j : [];
1294
- }
1295
- });
1296
- (_a = layout.annotations) === null || _a === void 0 ? void 0 : _a.forEach(function (annotation) {
1297
- var xMatches = gridX.flatMap(function (interval, idx) {
1298
- return (annotation === null || annotation === void 0 ? void 0 : annotation.x) >= interval[0] && (annotation === null || annotation === void 0 ? void 0 : annotation.x) <= interval[1] ? [idx] : [];
1299
1333
  });
1300
- var yMatch = gridY.findIndex(function (interval, yIndex) {
1301
- return xMatches.includes(yIndex) &&
1302
- (annotation === null || annotation === void 0 ? void 0 : annotation.y) >= interval[0] &&
1303
- (annotation === null || annotation === void 0 ? void 0 : annotation.y) <= interval[1];
1304
- });
1305
- if (yMatch !== -1) {
1306
- if (annotations[yMatch] === undefined) {
1307
- annotations[yMatch] = {};
1308
- }
1309
- if ((annotation === null || annotation === void 0 ? void 0 : annotation.textangle) === 90) {
1310
- annotations[yMatch].yAnnotation = annotation.text;
1311
- }
1312
- else {
1313
- annotations[yMatch].xAnnotation = annotation.text;
1314
- }
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);
1315
1350
  }
1316
1351
  });
1317
- 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) {
1318
1376
  var uniqueXIntervals_1 = new Map();
1319
- gridX.forEach(function (interval) {
1320
- var key = "".concat(interval[0], "-").concat(interval[1]);
1377
+ domainX.forEach(function (interval) {
1378
+ var key = "".concat(interval.start, "-").concat(interval.end);
1321
1379
  if (!uniqueXIntervals_1.has(key)) {
1322
1380
  uniqueXIntervals_1.set(key, interval);
1323
1381
  }
1324
1382
  });
1325
- var minXInterval_1 = Math.min.apply(Math, Array.from(uniqueXIntervals_1.values()).map(function (interval) { return interval[1] - interval[0]; }));
1326
- templateColumns = Array.from(uniqueXIntervals_1.values())
1327
- .map(function (interval) { return "".concat((interval[1] - interval[0]) / minXInterval_1, "fr"); })
1328
- .join(' ');
1329
- var columnNumber_1 = 1;
1330
- var lastIntervalEnd_1 = 0;
1331
- gridX.forEach(function (interval, index) {
1332
- if (interval.length === 0) {
1333
- return;
1334
- }
1335
- 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
1336
1393
  var annotationProps = annotations[index];
1337
1394
  var xAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.xAnnotation;
1338
- if (interval[0] < lastIntervalEnd_1) {
1339
- columnNumber_1 = 1;
1340
- }
1341
- lastIntervalEnd_1 = interval[1];
1342
1395
  var row = {
1343
1396
  row: -1,
1344
- column: columnNumber_1,
1397
+ column: columnNumber,
1345
1398
  xAnnotation: xAnnotation,
1399
+ xDomain: interval,
1400
+ yDomain: { start: 0, end: 1 }, // Default yDomain for x-axis
1346
1401
  };
1347
1402
  gridLayout[cellName] = row;
1348
- columnNumber_1 += 1;
1349
1403
  });
1350
1404
  }
1351
- var numColumns = Math.max.apply(Math, Object.values(gridLayout).map(function (cell) { var _a; return (_a = cell.column) !== null && _a !== void 0 ? _a : 0; }));
1352
- var columnFill = {};
1353
- for (var i = 1; i <= numColumns; i++) {
1354
- columnFill[i] = { row: 1, fillDomain: 0 };
1355
- }
1356
- if (gridY.length > 0) {
1405
+ if (domainY.length > 0) {
1357
1406
  var uniqueYIntervals_1 = new Map();
1358
- gridY.forEach(function (interval) {
1359
- var key = "".concat(interval[0], "-").concat(interval[1]);
1407
+ domainY.forEach(function (interval) {
1408
+ var key = "".concat(interval.start, "-").concat(interval.end);
1360
1409
  if (!uniqueYIntervals_1.has(key)) {
1361
1410
  uniqueYIntervals_1.set(key, interval);
1362
1411
  }
1363
1412
  });
1364
- var minYInterval_1 = Math.min.apply(Math, Array.from(uniqueYIntervals_1.values()).map(function (interval) { return interval[1] - interval[0]; }));
1365
- templateRows = Array.from(uniqueYIntervals_1.values())
1366
- .map(function (interval) { return "".concat((interval[1] - interval[0]) / minYInterval_1, "fr"); })
1367
- .join(' ');
1368
- gridY.forEach(function (interval, index) {
1369
- if (interval.length === 0) {
1370
- return;
1371
- }
1372
- 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
1373
1424
  var annotationProps = annotations[index];
1374
1425
  var yAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.yAnnotation;
1375
1426
  var cell = gridLayout[cellName];
1376
1427
  if (cell !== undefined) {
1377
- cell.row = columnFill[cell.column].row;
1428
+ cell.row = rowNumber;
1378
1429
  cell.yAnnotation = yAnnotation;
1430
+ cell.yDomain = interval;
1379
1431
  }
1380
- columnFill[cell.column].fillDomain = interval[1];
1381
- columnFill[cell.column].row += 1;
1382
1432
  });
1383
1433
  }
1384
- // reverse the order of rows in grid layout from bottom-top to top-bottom as required by CSS grid
1385
- var reversedGridLayout = {};
1386
- // find the maximum row number
1387
- var maxRowNumber = Math.max.apply(Math, Object.values(gridLayout).map(function (cell) { var _a; return (_a = cell.row) !== null && _a !== void 0 ? _a : 0; }));
1388
- // iterate over the gridLayout and reverse the row numbers
1389
- Object.keys(gridLayout).forEach(function (key) {
1390
- var cell = gridLayout[key];
1391
- if (cell.row !== undefined) {
1392
- // reverse the row number
1393
- cell.row = maxRowNumber - cell.row + 1;
1394
- }
1395
- reversedGridLayout[key] = cell;
1396
- });
1397
1434
  return {
1398
1435
  templateRows: templateRows,
1399
1436
  templateColumns: templateColumns,
1400
- layout: reversedGridLayout,
1437
+ layout: gridLayout,
1438
+ };
1439
+ };
1440
+ /**
1441
+ * @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/category_order_defaults.js#L50}
1442
+ */
1443
+ var getAxisCategoryOrderProps = function (data, layout) {
1444
+ var result = {};
1445
+ var axesById = {
1446
+ x: layout === null || layout === void 0 ? void 0 : layout.xaxis,
1447
+ y: layout === null || layout === void 0 ? void 0 : layout.yaxis,
1401
1448
  };
1449
+ Object.keys(axesById).forEach(function (axId) {
1450
+ var ax = axesById[axId];
1451
+ var axLetter = axId[0];
1452
+ var propName = "".concat(axLetter, "AxisCategoryOrder");
1453
+ var values = [];
1454
+ data.forEach(function (series) {
1455
+ var _a;
1456
+ (_a = series[axLetter]) === null || _a === void 0 ? void 0 : _a.forEach(function (val) {
1457
+ if (!isInvalidValue(val)) {
1458
+ values.push(val);
1459
+ }
1460
+ });
1461
+ });
1462
+ var isAxisTypeCategory = (ax === null || ax === void 0 ? void 0 : ax.type) === 'category' || (isStringArray(values) && !isNumberArray(values) && !isDateArray(values));
1463
+ if (!isAxisTypeCategory) {
1464
+ return;
1465
+ }
1466
+ var isValidArray = isArrayOrTypedArray(ax === null || ax === void 0 ? void 0 : ax.categoryarray) && ax.categoryarray.length > 0;
1467
+ if (isValidArray && (!(ax === null || ax === void 0 ? void 0 : ax.categoryorder) || ax.categoryorder === 'array')) {
1468
+ result[propName] = ax.categoryarray;
1469
+ return;
1470
+ }
1471
+ if (!(ax === null || ax === void 0 ? void 0 : ax.categoryorder) || ax.categoryorder === 'trace' || ax.categoryorder === 'array') {
1472
+ var categoriesInTraceOrder = Array.from(new Set(values));
1473
+ result[propName] = categoriesInTraceOrder;
1474
+ return;
1475
+ }
1476
+ result[propName] = ax.categoryorder;
1477
+ });
1478
+ return result;
1402
1479
  };
1403
1480
  //# sourceMappingURL=PlotlySchemaAdapter.js.map