@fluentui/react-charting 5.24.2 → 5.24.4

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 (192) hide show
  1. package/CHANGELOG.json +79 -1
  2. package/CHANGELOG.md +28 -2
  3. package/dist/react-charting.d.ts +204 -38
  4. package/dist/react-charting.js +1 -1
  5. package/dist/react-charting.min.js +1 -1
  6. package/etc/react-charting.api.md +65 -12
  7. package/lib/ScatterChart.d.ts +1 -0
  8. package/lib/ScatterChart.js +2 -0
  9. package/lib/ScatterChart.js.map +1 -0
  10. package/lib/components/AreaChart/AreaChart.base.d.ts +1 -0
  11. package/lib/components/AreaChart/AreaChart.base.js +4 -1
  12. package/lib/components/AreaChart/AreaChart.base.js.map +1 -1
  13. package/lib/components/CommonComponents/CartesianChart.base.js +47 -11
  14. package/lib/components/CommonComponents/CartesianChart.base.js.map +1 -1
  15. package/lib/components/CommonComponents/CartesianChart.styles.js +48 -26
  16. package/lib/components/CommonComponents/CartesianChart.styles.js.map +1 -1
  17. package/lib/components/CommonComponents/CartesianChart.types.d.ts +33 -3
  18. package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
  19. package/lib/components/DeclarativeChart/DeclarativeChart.js +157 -78
  20. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  21. package/lib/components/DeclarativeChart/PlotlyColorAdapter.d.ts +2 -1
  22. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +9 -1
  23. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
  24. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +28 -13
  25. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +317 -126
  26. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  27. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.d.ts +2 -0
  28. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +22 -3
  29. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
  30. package/lib/components/HeatMapChart/HeatMapChart.base.d.ts +7 -0
  31. package/lib/components/HeatMapChart/HeatMapChart.base.js +95 -37
  32. package/lib/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
  33. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.d.ts +3 -0
  34. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +24 -3
  35. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
  36. package/lib/components/ScatterChart/ScatterChart.base.d.ts +7 -0
  37. package/lib/components/ScatterChart/ScatterChart.base.js +482 -0
  38. package/lib/components/ScatterChart/ScatterChart.base.js.map +1 -0
  39. package/lib/components/ScatterChart/ScatterChart.d.ts +7 -0
  40. package/lib/components/ScatterChart/ScatterChart.js +10 -0
  41. package/lib/components/ScatterChart/ScatterChart.js.map +1 -0
  42. package/lib/components/ScatterChart/ScatterChart.styles.d.ts +2 -0
  43. package/lib/components/ScatterChart/ScatterChart.styles.js +19 -0
  44. package/lib/components/ScatterChart/ScatterChart.styles.js.map +1 -0
  45. package/lib/components/ScatterChart/ScatterChart.types.d.ts +47 -0
  46. package/lib/components/ScatterChart/ScatterChart.types.js +2 -0
  47. package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -0
  48. package/lib/components/ScatterChart/index.d.ts +2 -0
  49. package/lib/components/ScatterChart/index.js +3 -0
  50. package/lib/components/ScatterChart/index.js.map +1 -0
  51. package/lib/components/VerticalBarChart/VerticalBarChart.base.d.ts +2 -0
  52. package/lib/components/VerticalBarChart/VerticalBarChart.base.js +27 -6
  53. package/lib/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
  54. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.d.ts +3 -0
  55. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +48 -31
  56. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
  57. package/lib/index.d.ts +3 -1
  58. package/lib/index.js +1 -0
  59. package/lib/index.js.map +1 -1
  60. package/lib/types/IDataPoint.d.ts +91 -11
  61. package/lib/types/IDataPoint.js.map +1 -1
  62. package/lib/utilities/SVGTooltipText.d.ts +4 -0
  63. package/lib/utilities/SVGTooltipText.js +1 -2
  64. package/lib/utilities/SVGTooltipText.js.map +1 -1
  65. package/lib/utilities/utilities.d.ts +32 -5
  66. package/lib/utilities/utilities.js +132 -2
  67. package/lib/utilities/utilities.js.map +1 -1
  68. package/lib-amd/ScatterChart.d.ts +1 -0
  69. package/lib-amd/ScatterChart.js +6 -0
  70. package/lib-amd/ScatterChart.js.map +1 -0
  71. package/lib-amd/components/AreaChart/AreaChart.base.d.ts +1 -0
  72. package/lib-amd/components/AreaChart/AreaChart.base.js +4 -1
  73. package/lib-amd/components/AreaChart/AreaChart.base.js.map +1 -1
  74. package/lib-amd/components/CommonComponents/CartesianChart.base.js +47 -11
  75. package/lib-amd/components/CommonComponents/CartesianChart.base.js.map +1 -1
  76. package/lib-amd/components/CommonComponents/CartesianChart.styles.js +48 -26
  77. package/lib-amd/components/CommonComponents/CartesianChart.styles.js.map +1 -1
  78. package/lib-amd/components/CommonComponents/CartesianChart.types.d.ts +33 -3
  79. package/lib-amd/components/CommonComponents/CartesianChart.types.js.map +1 -1
  80. package/lib-amd/components/DeclarativeChart/DeclarativeChart.js +155 -78
  81. package/lib-amd/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  82. package/lib-amd/components/DeclarativeChart/PlotlyColorAdapter.d.ts +2 -1
  83. package/lib-amd/components/DeclarativeChart/PlotlyColorAdapter.js +11 -2
  84. package/lib-amd/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
  85. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +28 -13
  86. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +327 -134
  87. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  88. package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.d.ts +2 -0
  89. package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +21 -2
  90. package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
  91. package/lib-amd/components/HeatMapChart/HeatMapChart.base.d.ts +7 -0
  92. package/lib-amd/components/HeatMapChart/HeatMapChart.base.js +94 -36
  93. package/lib-amd/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
  94. package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.d.ts +3 -0
  95. package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +23 -2
  96. package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
  97. package/lib-amd/components/ScatterChart/ScatterChart.base.d.ts +7 -0
  98. package/lib-amd/components/ScatterChart/ScatterChart.base.js +476 -0
  99. package/lib-amd/components/ScatterChart/ScatterChart.base.js.map +1 -0
  100. package/lib-amd/components/ScatterChart/ScatterChart.d.ts +7 -0
  101. package/lib-amd/components/ScatterChart/ScatterChart.js +12 -0
  102. package/lib-amd/components/ScatterChart/ScatterChart.js.map +1 -0
  103. package/lib-amd/components/ScatterChart/ScatterChart.styles.d.ts +2 -0
  104. package/lib-amd/components/ScatterChart/ScatterChart.styles.js +23 -0
  105. package/lib-amd/components/ScatterChart/ScatterChart.styles.js.map +1 -0
  106. package/lib-amd/components/ScatterChart/ScatterChart.types.d.ts +47 -0
  107. package/lib-amd/components/ScatterChart/ScatterChart.types.js +5 -0
  108. package/lib-amd/components/ScatterChart/ScatterChart.types.js.map +1 -0
  109. package/lib-amd/components/ScatterChart/index.d.ts +2 -0
  110. package/lib-amd/components/ScatterChart/index.js +7 -0
  111. package/lib-amd/components/ScatterChart/index.js.map +1 -0
  112. package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.d.ts +2 -0
  113. package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js +26 -5
  114. package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
  115. package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.d.ts +3 -0
  116. package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +47 -30
  117. package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
  118. package/lib-amd/index.d.ts +3 -1
  119. package/lib-amd/index.js +3 -2
  120. package/lib-amd/index.js.map +1 -1
  121. package/lib-amd/types/IDataPoint.d.ts +91 -11
  122. package/lib-amd/types/IDataPoint.js.map +1 -1
  123. package/lib-amd/utilities/SVGTooltipText.d.ts +4 -0
  124. package/lib-amd/utilities/SVGTooltipText.js +1 -2
  125. package/lib-amd/utilities/SVGTooltipText.js.map +1 -1
  126. package/lib-amd/utilities/utilities.d.ts +32 -5
  127. package/lib-amd/utilities/utilities.js +135 -2
  128. package/lib-amd/utilities/utilities.js.map +1 -1
  129. package/lib-commonjs/ScatterChart.d.ts +1 -0
  130. package/lib-commonjs/ScatterChart.js +5 -0
  131. package/lib-commonjs/ScatterChart.js.map +1 -0
  132. package/lib-commonjs/components/AreaChart/AreaChart.base.d.ts +1 -0
  133. package/lib-commonjs/components/AreaChart/AreaChart.base.js +4 -1
  134. package/lib-commonjs/components/AreaChart/AreaChart.base.js.map +1 -1
  135. package/lib-commonjs/components/CommonComponents/CartesianChart.base.js +47 -11
  136. package/lib-commonjs/components/CommonComponents/CartesianChart.base.js.map +1 -1
  137. package/lib-commonjs/components/CommonComponents/CartesianChart.styles.js +48 -26
  138. package/lib-commonjs/components/CommonComponents/CartesianChart.styles.js.map +1 -1
  139. package/lib-commonjs/components/CommonComponents/CartesianChart.types.d.ts +33 -3
  140. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
  141. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +157 -78
  142. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  143. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.d.ts +2 -1
  144. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +11 -2
  145. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
  146. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +28 -13
  147. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +327 -134
  148. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  149. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.d.ts +2 -0
  150. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +21 -2
  151. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
  152. package/lib-commonjs/components/HeatMapChart/HeatMapChart.base.d.ts +7 -0
  153. package/lib-commonjs/components/HeatMapChart/HeatMapChart.base.js +94 -36
  154. package/lib-commonjs/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
  155. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.d.ts +3 -0
  156. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +23 -2
  157. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
  158. package/lib-commonjs/components/ScatterChart/ScatterChart.base.d.ts +7 -0
  159. package/lib-commonjs/components/ScatterChart/ScatterChart.base.js +485 -0
  160. package/lib-commonjs/components/ScatterChart/ScatterChart.base.js.map +1 -0
  161. package/lib-commonjs/components/ScatterChart/ScatterChart.d.ts +7 -0
  162. package/lib-commonjs/components/ScatterChart/ScatterChart.js +13 -0
  163. package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -0
  164. package/lib-commonjs/components/ScatterChart/ScatterChart.styles.d.ts +2 -0
  165. package/lib-commonjs/components/ScatterChart/ScatterChart.styles.js +23 -0
  166. package/lib-commonjs/components/ScatterChart/ScatterChart.styles.js.map +1 -0
  167. package/lib-commonjs/components/ScatterChart/ScatterChart.types.d.ts +47 -0
  168. package/lib-commonjs/components/ScatterChart/ScatterChart.types.js +3 -0
  169. package/lib-commonjs/components/ScatterChart/ScatterChart.types.js.map +1 -0
  170. package/lib-commonjs/components/ScatterChart/index.d.ts +2 -0
  171. package/lib-commonjs/components/ScatterChart/index.js +6 -0
  172. package/lib-commonjs/components/ScatterChart/index.js.map +1 -0
  173. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.d.ts +2 -0
  174. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js +26 -5
  175. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
  176. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.d.ts +3 -0
  177. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +47 -30
  178. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
  179. package/lib-commonjs/index.d.ts +3 -1
  180. package/lib-commonjs/index.js +3 -1
  181. package/lib-commonjs/index.js.map +1 -1
  182. package/lib-commonjs/types/IDataPoint.d.ts +91 -11
  183. package/lib-commonjs/types/IDataPoint.js.map +1 -1
  184. package/lib-commonjs/utilities/SVGTooltipText.d.ts +4 -0
  185. package/lib-commonjs/utilities/SVGTooltipText.js +1 -2
  186. package/lib-commonjs/utilities/SVGTooltipText.js.map +1 -1
  187. package/lib-commonjs/utilities/utilities.d.ts +32 -5
  188. package/lib-commonjs/utilities/utilities.js +135 -2
  189. package/lib-commonjs/utilities/utilities.js.map +1 -1
  190. package/package.json +2 -2
  191. package/src/components/CommonComponents/CartesianChart.types.ts +45 -2
  192. package/src/components/ScatterChart/ScatterChart.types.ts +67 -0
@@ -1,7 +1,7 @@
1
- define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../../utilities/colors", "../GaugeChart/index", "../../utilities/utilities", "@fluentui/chart-utilities", "d3-time-format", "d3-shape", "./PlotlyColorAdapter"], function (require, exports, tslib_1, d3_array_1, d3_scale_1, d3_format_1, colors_1, index_1, utilities_1, chart_utilities_1, d3_time_format_1, d3_shape_1, PlotlyColorAdapter_1) {
1
+ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../../utilities/colors", "../GaugeChart/index", "../../utilities/utilities", "@fluentui/chart-utilities", "d3-shape", "./PlotlyColorAdapter", "d3-color"], function (require, exports, tslib_1, d3_array_1, d3_scale_1, d3_format_1, colors_1, index_1, utilities_1, chart_utilities_1, d3_shape_1, PlotlyColorAdapter_1, d3_color_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.getValidXYRanges = exports.getNumberAtIndexOrDefault = exports.isStringArray = exports.findArrayAttributes = exports.projectPolarToCartesian = exports.transformPlotlyJsonToChartTableProps = exports.transformPlotlyJsonToGaugeProps = exports.transformPlotlyJsonToSankeyProps = exports.transformPlotlyJsonToHeatmapProps = exports.transformPlotlyJsonToHorizontalBarWithAxisProps = exports.transformPlotlyJsonToScatterChartProps = exports.transformPlotlyJsonToVBCProps = exports.transformPlotlyJsonToGVBCProps = exports.transformPlotlyJsonToVSBCProps = exports.transformPlotlyJsonToDonutProps = exports.resolveXAxisPoint = exports._getGaugeAxisColor = exports.correctYearMonth = exports.isMonthArray = void 0;
4
+ 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;
5
5
  var dashOptions = {
6
6
  dot: {
7
7
  strokeDasharray: '1, 5',
@@ -40,17 +40,6 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
40
40
  lineBorderWidth: '4',
41
41
  },
42
42
  };
43
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
- var isMonth = function (possiblyMonthValue) {
45
- var parseFullMonth = (0, d3_time_format_1.timeParse)('%B');
46
- var parseShortMonth = (0, d3_time_format_1.timeParse)('%b');
47
- return parseFullMonth(possiblyMonthValue) !== null || parseShortMonth(possiblyMonthValue) !== null;
48
- };
49
- var isMonthArray = function (data) {
50
- /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
51
- return (0, chart_utilities_1.isArrayOfType)(data, function (value) { return isMonth(value) || value === null; });
52
- };
53
- exports.isMonthArray = isMonthArray;
54
43
  function getTitles(layout) {
55
44
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
56
45
  var titles = {
@@ -98,8 +87,9 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
98
87
  return xValues;
99
88
  };
100
89
  exports.correctYearMonth = correctYearMonth;
101
- var usesSecondaryYScale = function (series) {
102
- return series.yaxis === 'y2';
90
+ var usesSecondaryYScale = function (series, layout) {
91
+ var _a, _b;
92
+ return series.yaxis === 'y2' && (((_a = layout === null || layout === void 0 ? void 0 : layout.yaxis2) === null || _a === void 0 ? void 0 : _a.anchor) === 'x' || ((_b = layout === null || layout === void 0 ? void 0 : layout.yaxis2) === null || _b === void 0 ? void 0 : _b.side) === 'right');
103
93
  };
104
94
  var getSecondaryYAxisValues = function (data, layout, maxAllowedMinY, minAllowedMaxY) {
105
95
  var _a, _b, _c, _d;
@@ -107,7 +97,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
107
97
  var yMinValue;
108
98
  var yMaxValue;
109
99
  data.forEach(function (series) {
110
- if (usesSecondaryYScale(series)) {
100
+ if (usesSecondaryYScale(series, layout)) {
111
101
  containsSecondaryYAxis = true;
112
102
  var yValues = series.y;
113
103
  if (yValues) {
@@ -166,7 +156,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
166
156
  return x;
167
157
  };
168
158
  exports.resolveXAxisPoint = resolveXAxisPoint;
169
- var transformPlotlyJsonToDonutProps = function (input, colorMap, colorwayType, isDarkTheme) {
159
+ var transformPlotlyJsonToDonutProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
170
160
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
171
161
  var firstData = input.data[0];
172
162
  // extract colors for each series only once
@@ -219,13 +209,13 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
219
209
  };
220
210
  };
221
211
  exports.transformPlotlyJsonToDonutProps = transformPlotlyJsonToDonutProps;
222
- var transformPlotlyJsonToVSBCProps = function (input, colorMap, colorwayType, isDarkTheme, fallbackVSBC) {
212
+ var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme, fallbackVSBC) {
223
213
  var _a, _b, _c;
224
214
  var mapXToDataPoints = {};
225
215
  var yMaxValue = 0;
226
216
  var yMinValue = 0;
227
217
  var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
228
- var _d = getLegendProps(input.data, input.layout), legends = _d.legends, hideLegend = _d.hideLegend;
218
+ var _d = getLegendProps(input.data, input.layout, isMultiPlot), legends = _d.legends, hideLegend = _d.hideLegend;
229
219
  var colorScale = undefined;
230
220
  input.data.forEach(function (series, index1) {
231
221
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
@@ -242,7 +232,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
242
232
  var extractedLineColors = (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, (_q = series.line) === null || _q === void 0 ? void 0 : _q.color, colorMap, isDarkTheme);
243
233
  var xValues = series.x;
244
234
  var isXDate = (0, chart_utilities_1.isDateArray)(xValues);
245
- var isXString = (0, exports.isStringArray)(xValues);
235
+ var isXString = (0, chart_utilities_1.isStringArray)(xValues);
246
236
  var isXNumber = (0, chart_utilities_1.isNumberArray)(xValues);
247
237
  var validXYRanges = (0, exports.getValidXYRanges)(series);
248
238
  validXYRanges.forEach(function (_a, rangeIdx) {
@@ -265,12 +255,13 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
265
255
  ? (_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]
266
256
  : 0)
267
257
  : (0, PlotlyColorAdapter_1.resolveColor)(extractedBarColors, index2, legend, colorMap, isDarkTheme);
258
+ var opacity = (0, PlotlyColorAdapter_1.getOpacity)(series, index2);
268
259
  var yVal = rangeYValues[index2];
269
260
  if (series.type === 'bar') {
270
261
  mapXToDataPoints[x].chartData.push({
271
262
  legend: legend,
272
263
  data: yVal,
273
- color: color,
264
+ color: (_e = (0, d3_color_1.rgb)(color).copy({ opacity: opacity }).formatHex8()) !== null && _e !== void 0 ? _e : color,
274
265
  });
275
266
  if (typeof yVal === 'number') {
276
267
  yMaxValue = Math.max(yMaxValue, yVal);
@@ -279,21 +270,16 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
279
270
  else if (series.type === 'scatter' || !!fallbackVSBC) {
280
271
  var lineColor = (0, PlotlyColorAdapter_1.resolveColor)(extractedLineColors, index1, legend, colorMap, isDarkTheme);
281
272
  var lineOptions = getLineOptions(series.line);
282
- var dashType = ((_e = series.line) === null || _e === void 0 ? void 0 : _e.dash) || 'solid';
283
- var legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot'
284
- ? 'dottedLine'
285
- : ((_f = series.mode) === null || _f === void 0 ? void 0 : _f.includes('markers'))
286
- ? 'circle'
287
- : 'default';
273
+ var legendShape = getLegendShape(series);
288
274
  mapXToDataPoints[x].lineData.push({
289
275
  legend: legend + (validXYRanges.length > 1 ? ".".concat(rangeIdx + 1) : ''),
290
276
  legendShape: legendShape,
291
277
  y: yVal,
292
- color: lineColor,
278
+ color: (_f = (0, d3_color_1.rgb)(lineColor).copy({ opacity: opacity }).formatHex8()) !== null && _f !== void 0 ? _f : color,
293
279
  lineOptions: tslib_1.__assign(tslib_1.__assign({}, (lineOptions !== null && lineOptions !== void 0 ? lineOptions : {})), { mode: series.mode }),
294
- useSecondaryYScale: usesSecondaryYScale(series),
280
+ useSecondaryYScale: usesSecondaryYScale(series, input.layout),
295
281
  });
296
- if (!usesSecondaryYScale(series) && typeof yVal === 'number') {
282
+ if (!usesSecondaryYScale(series, input.layout) && typeof yVal === 'number') {
297
283
  yMaxValue = Math.max(yMaxValue, yVal);
298
284
  yMinValue = Math.min(yMinValue, yVal);
299
285
  }
@@ -302,7 +288,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
302
288
  });
303
289
  });
304
290
  var _e = getTitles(input.layout), chartTitle = _e.chartTitle, xAxisTitle = _e.xAxisTitle, yAxisTitle = _e.yAxisTitle;
305
- return 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 });
291
+ 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));
306
292
  };
307
293
  exports.transformPlotlyJsonToVSBCProps = transformPlotlyJsonToVSBCProps;
308
294
  var createColorScale = function (layout, series) {
@@ -321,11 +307,11 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
321
307
  var scaleColors = scale.map(function (item) { return item[1]; });
322
308
  return (0, d3_scale_1.scaleLinear)().domain(scaleDomain).range(scaleColors);
323
309
  };
324
- var transformPlotlyJsonToGVBCProps = function (input, colorMap, colorwayType, isDarkTheme) {
310
+ var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
325
311
  var _a, _b, _c;
326
312
  var mapXToDataPoints = {};
327
313
  var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, 0, 0);
328
- var _d = getLegendProps(input.data, input.layout), legends = _d.legends, hideLegend = _d.hideLegend;
314
+ var _d = getLegendProps(input.data, input.layout, isMultiPlot), legends = _d.legends, hideLegend = _d.hideLegend;
329
315
  var colorScale = undefined;
330
316
  input.data.forEach(function (series, index1) {
331
317
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
@@ -338,7 +324,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
338
324
  // extract colors for each series only once
339
325
  var extractedColors = (0, PlotlyColorAdapter_1.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);
340
326
  (_m = series.x) === null || _m === void 0 ? void 0 : _m.forEach(function (x, xIndex) {
341
- var _a, _b, _c, _d, _e;
327
+ var _a, _b, _c, _d, _e, _f;
342
328
  if ((0, chart_utilities_1.isInvalidValue)(x) || (0, chart_utilities_1.isInvalidValue)((_a = series.y) === null || _a === void 0 ? void 0 : _a[xIndex])) {
343
329
  return;
344
330
  }
@@ -352,26 +338,27 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
352
338
  ? colorScale((0, chart_utilities_1.isArrayOrTypedArray)((_b = series.marker) === null || _b === void 0 ? void 0 : _b.color)
353
339
  ? (_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]
354
340
  : 0)
355
- : (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, index1, legend, colorMap, isDarkTheme);
341
+ : (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, xIndex, legend, colorMap, isDarkTheme);
342
+ var opacity = (0, PlotlyColorAdapter_1.getOpacity)(series, xIndex);
356
343
  mapXToDataPoints[x].series.push({
357
344
  key: legend,
358
345
  data: series.y[xIndex],
359
346
  xAxisCalloutData: x,
360
- color: color,
347
+ color: (_f = (0, d3_color_1.rgb)(color).copy({ opacity: opacity }).formatHex8()) !== null && _f !== void 0 ? _f : color,
361
348
  legend: legend,
362
- useSecondaryYScale: usesSecondaryYScale(series),
349
+ useSecondaryYScale: usesSecondaryYScale(series, input.layout),
363
350
  });
364
351
  }
365
352
  });
366
353
  });
367
354
  var _e = getTitles(input.layout), chartTitle = _e.chartTitle, xAxisTitle = _e.xAxisTitle, yAxisTitle = _e.yAxisTitle;
368
- return 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 });
355
+ 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));
369
356
  };
370
357
  exports.transformPlotlyJsonToGVBCProps = transformPlotlyJsonToGVBCProps;
371
- var transformPlotlyJsonToVBCProps = function (input, colorMap, colorwayType, isDarkTheme) {
358
+ var transformPlotlyJsonToVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
372
359
  var _a, _b, _c;
373
360
  var vbcData = [];
374
- var _d = getLegendProps(input.data, input.layout), legends = _d.legends, hideLegend = _d.hideLegend;
361
+ var _d = getLegendProps(input.data, input.layout, isMultiPlot), legends = _d.legends, hideLegend = _d.hideLegend;
375
362
  var colorScale = undefined;
376
363
  input.data.forEach(function (series, seriesIdx) {
377
364
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
@@ -396,7 +383,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
396
383
  xValues.push(xVal);
397
384
  yValues.push(yVal);
398
385
  });
399
- var isXString = (0, exports.isStringArray)(xValues);
386
+ var isXString = (0, chart_utilities_1.isStringArray)(xValues);
400
387
  // TODO: In case of a single bin, add an empty bin of the same size to prevent the
401
388
  // default bar width from being used and ensure the bar spans the full intended range.
402
389
  var xBins = createBins(xValues, (_m = series.xbins) === null || _m === void 0 ? void 0 : _m.start, (_o = series.xbins) === null || _o === void 0 ? void 0 : _o.end, (_p = series.xbins) === null || _p === void 0 ? void 0 : _p.size);
@@ -414,7 +401,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
414
401
  return yVal;
415
402
  });
416
403
  xBins.forEach(function (bin, index) {
417
- var _a, _b, _c, _d;
404
+ var _a, _b, _c, _d, _e;
418
405
  var legend = legends[seriesIdx];
419
406
  // resolve color for each legend's bars from the colorscale or extracted colors
420
407
  var color = colorScale
@@ -422,37 +409,47 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
422
409
  ? (_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]
423
410
  : 0)
424
411
  : (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, index, legend, colorMap, isDarkTheme);
412
+ var opacity = (0, PlotlyColorAdapter_1.getOpacity)(series, index);
425
413
  var yVal = calculateHistNorm(series.histnorm, y[index], total, isXString ? bin.length : getBinSize(bin));
426
- vbcData.push(tslib_1.__assign({ x: isXString ? bin.join(', ') : getBinCenter(bin), y: yVal, legend: legend, color: color }, (isXString
414
+ vbcData.push(tslib_1.__assign({ x: isXString ? bin.join(', ') : getBinCenter(bin), y: yVal, legend: legend, color: (_e = (0, d3_color_1.rgb)(color).copy({ opacity: opacity }).formatHex8()) !== null && _e !== void 0 ? _e : color }, (isXString
427
415
  ? {}
428
416
  : { xAxisCalloutData: "[".concat(bin.x0, " - ").concat(bin.x1, ")") })));
429
417
  });
430
418
  });
431
419
  var _e = getTitles(input.layout), chartTitle = _e.chartTitle, xAxisTitle = _e.xAxisTitle, yAxisTitle = _e.yAxisTitle;
432
- return {
433
- data: vbcData,
434
- width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width,
435
- height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350,
436
- supportNegativeData: true,
437
- chartTitle: chartTitle,
438
- xAxisTitle: xAxisTitle,
439
- yAxisTitle: yAxisTitle,
440
- mode: 'histogram',
441
- hideTickOverlap: true,
442
- maxBarWidth: 50,
443
- hideLegend: hideLegend,
444
- roundCorners: true,
445
- };
420
+ 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));
446
421
  };
447
422
  exports.transformPlotlyJsonToVBCProps = transformPlotlyJsonToVBCProps;
448
- var transformPlotlyJsonToScatterChartProps = function (input, isAreaChart, isScatterMarkers, colorMap, colorwayType, isDarkTheme) {
449
- var _a, _b, _c, _d, _e, _f;
423
+ var transformPlotlyJsonToAreaChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
424
+ return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'area', colorMap, colorwayType, isDarkTheme);
425
+ };
426
+ exports.transformPlotlyJsonToAreaChartProps = transformPlotlyJsonToAreaChartProps;
427
+ var transformPlotlyJsonToLineChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
428
+ return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'line', colorMap, colorwayType, isDarkTheme);
429
+ };
430
+ exports.transformPlotlyJsonToLineChartProps = transformPlotlyJsonToLineChartProps;
431
+ var transformPlotlyJsonToScatterChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
432
+ return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'scatter', colorMap, colorwayType, isDarkTheme);
433
+ };
434
+ exports.transformPlotlyJsonToScatterChartProps = transformPlotlyJsonToScatterChartProps;
435
+ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme) {
436
+ var _a, _b, _c, _d, _e, _f, _g;
437
+ var isScatterMarkers = [
438
+ 'markers',
439
+ 'text+markers',
440
+ 'markers+text',
441
+ 'lines+markers',
442
+ 'markers+line',
443
+ 'text+lines+markers',
444
+ ].includes((_a = input.data[0]) === null || _a === void 0 ? void 0 : _a.mode);
445
+ var isAreaChart = chartType === 'area';
446
+ var isScatterChart = chartType === 'scatter';
450
447
  var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
451
448
  var mode = 'tonexty';
452
- var _g = getLegendProps(input.data, input.layout), legends = _g.legends, hideLegend = _g.hideLegend;
449
+ var _h = getLegendProps(input.data, input.layout, isMultiPlot), legends = _h.legends, hideLegend = _h.hideLegend;
453
450
  var chartData = input.data
454
451
  .map(function (series, index) {
455
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
452
+ var _a, _b, _c, _d, _e, _f, _g;
456
453
  var colors = isScatterMarkers
457
454
  ? ((_a = series === null || series === void 0 ? void 0 : series.mode) === null || _a === void 0 ? void 0 : _a.includes('line'))
458
455
  ? (_b = series.line) === null || _b === void 0 ? void 0 : _b.color
@@ -461,25 +458,20 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
461
458
  // extract colors for each series only once
462
459
  var extractedColors = (0, PlotlyColorAdapter_1.extractColor)((_g = (_f = (_e = input.layout) === null || _e === void 0 ? void 0 : _e.template) === null || _f === void 0 ? void 0 : _f.layout) === null || _g === void 0 ? void 0 : _g.colorway, colorwayType, colors, colorMap, isDarkTheme);
463
460
  var xValues = series.x;
464
- var isXString = (0, exports.isStringArray)(xValues);
461
+ var isXString = (0, chart_utilities_1.isStringArray)(xValues);
465
462
  var isXDate = (0, chart_utilities_1.isDateArray)(xValues);
466
463
  var isXNumber = (0, chart_utilities_1.isNumberArray)(xValues);
467
- // string case is not possible for scatter chart as it is already filtered out in declarative chart
468
- var isXYearCategory = false;
464
+ var isXYearCategory = (0, chart_utilities_1.isYearArray)(series.x); // Consider year as categorical not numeric continuous axis
469
465
  var legend = legends[index];
470
466
  // resolve color for each legend's lines from the extracted colors
471
467
  var seriesColor = (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, index, legend, colorMap, isDarkTheme);
468
+ var seriesOpacity = (0, PlotlyColorAdapter_1.getOpacity)(series, index);
472
469
  mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
473
470
  var lineOptions = getLineOptions(series.line);
474
- var dashType = ((_h = series.line) === null || _h === void 0 ? void 0 : _h.dash) || 'solid';
475
- var legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot'
476
- ? 'dottedLine'
477
- : ((_j = series.mode) === null || _j === void 0 ? void 0 : _j.includes('markers'))
478
- ? 'circle'
479
- : 'default';
471
+ var legendShape = getLegendShape(series);
480
472
  var validXYRanges = (0, exports.getValidXYRanges)(series);
481
473
  return validXYRanges.map(function (_a, rangeIdx) {
482
- var _b;
474
+ var _b, _c;
483
475
  var rangeStart = _a[0], rangeEnd = _a[1];
484
476
  var rangeXValues = xValues.slice(rangeStart, rangeEnd);
485
477
  var rangeYValues = series.y.slice(rangeStart, rangeEnd);
@@ -498,31 +490,34 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
498
490
  ? { markerSize: series.marker.size }
499
491
  : {})), (textValues ? { text: textValues[i] } : {})));
500
492
  }),
501
- color: seriesColor,
493
+ color: (_c = (0, d3_color_1.rgb)(seriesColor).copy({ opacity: seriesOpacity }).formatHex8()) !== null && _c !== void 0 ? _c : seriesColor,
502
494
  lineOptions: tslib_1.__assign(tslib_1.__assign({}, (lineOptions !== null && lineOptions !== void 0 ? lineOptions : {})), { mode: series.mode }),
503
- useSecondaryYScale: usesSecondaryYScale(series),
495
+ useSecondaryYScale: usesSecondaryYScale(series, input.layout),
504
496
  };
505
497
  });
506
498
  })
507
499
  .flat();
508
500
  var yMinMaxValues = (0, utilities_1.findNumericMinMaxOfY)(chartData);
509
- var _h = getTitles(input.layout), chartTitle = _h.chartTitle, xAxisTitle = _h.xAxisTitle, yAxisTitle = _h.yAxisTitle;
501
+ var _j = getTitles(input.layout), chartTitle = _j.chartTitle, xAxisTitle = _j.xAxisTitle, yAxisTitle = _j.yAxisTitle;
510
502
  var numDataPoints = chartData.reduce(function (total, lineChartPoints) { return total + lineChartPoints.data.length; }, 0);
511
503
  var chartProps = {
512
504
  chartTitle: chartTitle,
513
505
  lineChartData: chartData,
514
506
  };
507
+ var scatterChartProps = {
508
+ chartTitle: chartTitle,
509
+ scatterChartData: chartData,
510
+ };
515
511
  if (isAreaChart) {
516
- return tslib_1.__assign(tslib_1.__assign({ data: chartProps, supportNegativeData: true, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle }, secondaryYAxisValues), { mode: mode, 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, hideTickOverlap: true, hideLegend: hideLegend, useUTC: false, optimizeLargeData: numDataPoints > 1000 });
512
+ 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 });
517
513
  }
518
514
  else {
519
- return tslib_1.__assign(tslib_1.__assign({ data: chartProps, supportNegativeData: true, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle }, secondaryYAxisValues), { roundedTicks: true, yMinValue: yMinMaxValues.startValue, yMaxValue: yMinMaxValues.endValue, width: (_d = input.layout) === null || _d === void 0 ? void 0 : _d.width, height: (_f = (_e = input.layout) === null || _e === void 0 ? void 0 : _e.height) !== null && _f !== void 0 ? _f : 350, hideTickOverlap: true, enableReflow: false, hideLegend: hideLegend, useUTC: false, optimizeLargeData: numDataPoints > 1000 });
515
+ 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 });
520
516
  }
521
517
  };
522
- exports.transformPlotlyJsonToScatterChartProps = transformPlotlyJsonToScatterChartProps;
523
- var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, colorMap, colorwayType, isDarkTheme) {
518
+ var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
524
519
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
525
- var _s = getLegendProps(input.data, input.layout), legends = _s.legends, hideLegend = _s.hideLegend;
520
+ var _s = getLegendProps(input.data, input.layout, isMultiPlot), legends = _s.legends, hideLegend = _s.hideLegend;
526
521
  var colorScale = undefined;
527
522
  var chartData = input.data
528
523
  .map(function (series, index) {
@@ -538,7 +533,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
538
533
  var legend = legends[index];
539
534
  return series.y
540
535
  .map(function (yValue, i) {
541
- var _a, _b, _c, _d, _e;
536
+ var _a, _b, _c, _d, _e, _f;
542
537
  if ((0, chart_utilities_1.isInvalidValue)((_a = series.x) === null || _a === void 0 ? void 0 : _a[i]) || (0, chart_utilities_1.isInvalidValue)(yValue)) {
543
538
  return null;
544
539
  }
@@ -548,19 +543,17 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
548
543
  ? (_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]
549
544
  : 0)
550
545
  : (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, i, legend, colorMap, isDarkTheme);
546
+ var opacity = (0, PlotlyColorAdapter_1.getOpacity)(series, i);
551
547
  return {
552
548
  x: series.x[i],
553
549
  y: yValue,
554
550
  legend: legend,
555
- color: color,
551
+ color: (_f = (0, d3_color_1.rgb)(color).copy({ opacity: opacity }).formatHex8()) !== null && _f !== void 0 ? _f : color,
556
552
  };
557
553
  })
558
554
  .filter(function (point) { return point !== null; });
559
555
  })
560
- .reverse()
561
- .flat()
562
- //reversing the order to invert the Y bars order as required by plotly.
563
- .reverse();
556
+ .flat();
564
557
  var chartHeight = (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.height) !== null && _b !== void 0 ? _b : 450;
565
558
  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;
566
559
  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;
@@ -570,27 +563,12 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
570
563
  var gapFactor = 1 / (1 + scalingFactor * numberOfRows);
571
564
  var barHeight = availableHeight / (numberOfRows * (1 + gapFactor));
572
565
  var _t = getTitles(input.layout), chartTitle = _t.chartTitle, xAxisTitle = _t.xAxisTitle, yAxisTitle = _t.yAxisTitle;
573
- return {
574
- data: chartData,
575
- chartTitle: chartTitle,
576
- xAxisTitle: xAxisTitle,
577
- yAxisTitle: yAxisTitle,
578
- secondaryYAxistitle: typeof ((_k = (_j = input.layout) === null || _j === void 0 ? void 0 : _j.yaxis2) === null || _k === void 0 ? void 0 : _k.title) === 'string'
566
+ 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'
579
567
  ? (_m = (_l = input.layout) === null || _l === void 0 ? void 0 : _l.yaxis2) === null || _m === void 0 ? void 0 : _m.title
580
- : ((_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) || '',
581
- barHeight: barHeight,
582
- showYAxisLables: true,
583
- height: chartHeight,
584
- width: (_r = input.layout) === null || _r === void 0 ? void 0 : _r.width,
585
- hideTickOverlap: true,
586
- hideLegend: hideLegend,
587
- noOfCharsToTruncate: 20,
588
- showYAxisLablesTooltip: true,
589
- roundCorners: true,
590
- };
568
+ : ((_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));
591
569
  };
592
570
  exports.transformPlotlyJsonToHorizontalBarWithAxisProps = transformPlotlyJsonToHorizontalBarWithAxisProps;
593
- var transformPlotlyJsonToHeatmapProps = function (input) {
571
+ var transformPlotlyJsonToHeatmapProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
594
572
  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;
595
573
  var firstData = input.data[0];
596
574
  var heatmapDataPoints = [];
@@ -610,8 +588,8 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
610
588
  yValues_1.push(firstData.y[index]);
611
589
  zValues_1.push(zVal);
612
590
  });
613
- var isXString_1 = (0, exports.isStringArray)(xValues_1);
614
- var isYString_1 = (0, exports.isStringArray)(yValues_1);
591
+ var isXString_1 = (0, chart_utilities_1.isStringArray)(xValues_1);
592
+ var isYString_1 = (0, chart_utilities_1.isStringArray)(yValues_1);
615
593
  var xBins_1 = createBins(xValues_1, (_b = firstData.xbins) === null || _b === void 0 ? void 0 : _b.start, (_c = firstData.xbins) === null || _c === void 0 ? void 0 : _c.end, (_d = firstData.xbins) === null || _d === void 0 ? void 0 : _d.size);
616
594
  var yBins_1 = createBins(yValues_1, (_e = firstData.ybins) === null || _e === void 0 ? void 0 : _e.start, (_f = firstData.ybins) === null || _f === void 0 ? void 0 : _f.end, (_g = firstData.ybins) === null || _g === void 0 ? void 0 : _g.size);
617
595
  var zBins_1 = yBins_1.map(function () { return xBins_1.map(function () { return []; }); });
@@ -703,25 +681,10 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
703
681
  ? colorscale.map(function (arr) { return arr[1]; })
704
682
  : defaultRange;
705
683
  var _9 = getTitles(input.layout), chartTitle = _9.chartTitle, xAxisTitle = _9.xAxisTitle, yAxisTitle = _9.yAxisTitle;
706
- return {
707
- data: [heatmapData],
708
- domainValuesForColorScale: domainValuesForColorScale,
709
- rangeValuesForColorScale: rangeValuesForColorScale,
710
- hideLegend: true,
711
- showYAxisLables: true,
712
- chartTitle: chartTitle,
713
- xAxisTitle: xAxisTitle,
714
- yAxisTitle: yAxisTitle,
715
- sortOrder: 'none',
716
- width: (_6 = input.layout) === null || _6 === void 0 ? void 0 : _6.width,
717
- height: (_8 = (_7 = input.layout) === null || _7 === void 0 ? void 0 : _7.height) !== null && _8 !== void 0 ? _8 : 350,
718
- hideTickOverlap: true,
719
- noOfCharsToTruncate: 20,
720
- showYAxisLablesTooltip: true,
721
- };
684
+ 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));
722
685
  };
723
686
  exports.transformPlotlyJsonToHeatmapProps = transformPlotlyJsonToHeatmapProps;
724
- var transformPlotlyJsonToSankeyProps = function (input, colorMap, colorwayType, isDarkTheme) {
687
+ var transformPlotlyJsonToSankeyProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
725
688
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
726
689
  var _m = input.data[0], link = _m.link, node = _m.node;
727
690
  var validLinks = ((_a = link === null || link === void 0 ? void 0 : link.value) !== null && _a !== void 0 ? _a : [])
@@ -769,7 +732,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
769
732
  };
770
733
  };
771
734
  exports.transformPlotlyJsonToSankeyProps = transformPlotlyJsonToSankeyProps;
772
- var transformPlotlyJsonToGaugeProps = function (input, colorMap, colorwayType, isDarkTheme) {
735
+ var transformPlotlyJsonToGaugeProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
773
736
  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, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25;
774
737
  var firstData = input.data[0];
775
738
  var stepsColors = ((_a = firstData.gauge) === null || _a === void 0 ? void 0 : _a.steps) ? firstData.gauge.steps.map(function (step) { return step.color; }) : undefined;
@@ -869,7 +832,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
869
832
  }
870
833
  return "".concat(prefix !== null && prefix !== void 0 ? prefix : '').concat(formatted).concat(suffix !== null && suffix !== void 0 ? suffix : '');
871
834
  };
872
- var transformPlotlyJsonToChartTableProps = function (input, colorMap, isDarkTheme) {
835
+ var transformPlotlyJsonToChartTableProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
873
836
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
874
837
  var tableData = input.data[0];
875
838
  var normalizeHeaders = function (values, header) {
@@ -1075,12 +1038,6 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
1075
1038
  }
1076
1039
  return Object.keys(lineOptions).length > 0 ? lineOptions : undefined;
1077
1040
  }
1078
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1079
- var isStringArray = function (arr) {
1080
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1081
- return (0, chart_utilities_1.isArrayOfType)(arr, function (value) { return typeof value === 'string' || value === null; });
1082
- };
1083
- exports.isStringArray = isStringArray;
1084
1041
  // TODO: Use binary search to find the appropriate bin for numeric value.
1085
1042
  var findBinIndex = function (bins, value, isString) {
1086
1043
  if (typeof value === 'undefined' || value === null) {
@@ -1104,7 +1061,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
1104
1061
  if (!data || data.length === 0) {
1105
1062
  return [];
1106
1063
  }
1107
- if ((0, exports.isStringArray)(data)) {
1064
+ if ((0, chart_utilities_1.isStringArray)(data)) {
1108
1065
  var categories_1 = Array.from(new Set(data));
1109
1066
  var start = typeof binStart === 'number' ? Math.ceil(binStart) : 0;
1110
1067
  var stop_1 = typeof binEnd === 'number' ? Math.floor(binEnd) + 1 : categories_1.length;
@@ -1175,7 +1132,48 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
1175
1132
  var factor = Math.pow(10, precision);
1176
1133
  return Math.round(value * factor) / factor;
1177
1134
  };
1178
- var getLegendProps = function (data, layout) {
1135
+ var getLegendShape = function (series) {
1136
+ var _a, _b;
1137
+ var dashType = ((_a = series.line) === null || _a === void 0 ? void 0 : _a.dash) || 'solid';
1138
+ if (dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot') {
1139
+ return 'dottedLine';
1140
+ }
1141
+ else if ((_b = series.mode) === null || _b === void 0 ? void 0 : _b.includes('markers')) {
1142
+ return 'circle';
1143
+ }
1144
+ return 'default';
1145
+ };
1146
+ var getAllupLegendsProps = function (input, colorMap, colorwayType, isDarkTheme) {
1147
+ var allupLegends = [];
1148
+ // reduce on showlegend boolean propperty. reduce should return true if at least one series has showlegend true
1149
+ var toShowLegend = input.data.reduce(function (acc, series) {
1150
+ return acc || series.showlegend === true;
1151
+ }, false);
1152
+ if (toShowLegend) {
1153
+ input.data.forEach(function (series, index) {
1154
+ var _a, _b, _c, _d, _e;
1155
+ var name = series.legendgroup;
1156
+ var color = ((_a = series.line) === null || _a === void 0 ? void 0 : _a.color) || ((_b = series.marker) === null || _b === void 0 ? void 0 : _b.color);
1157
+ var legendShape = getLegendShape(series);
1158
+ 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);
1159
+ if (name !== undefined && allupLegends.some(function (group) { return group.title === name; }) === false) {
1160
+ allupLegends.push({
1161
+ title: name,
1162
+ color: resolvedColor,
1163
+ shape: legendShape,
1164
+ });
1165
+ }
1166
+ });
1167
+ }
1168
+ return {
1169
+ legends: allupLegends,
1170
+ centerLegends: true,
1171
+ enabledWrapLines: true,
1172
+ canSelectMultipleLegends: true,
1173
+ };
1174
+ };
1175
+ exports.getAllupLegendsProps = getAllupLegendsProps;
1176
+ var getLegendProps = function (data, layout, isMultiPlot) {
1179
1177
  var legends = [];
1180
1178
  if (data.length === 1) {
1181
1179
  legends.push(data[0].name || '');
@@ -1185,10 +1183,11 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
1185
1183
  legends.push(series.name || "Series ".concat(index + 1));
1186
1184
  });
1187
1185
  }
1188
- var hideLegends = data.every(function (series) { return series.showlegend === false; });
1186
+ var hideLegendsData = data.every(function (series) { return series.showlegend === false; });
1187
+ var hideLegendsInferred = (layout === null || layout === void 0 ? void 0 : layout.showlegend) === false || ((layout === null || layout === void 0 ? void 0 : layout.showlegend) !== true && legends.length < 2);
1189
1188
  return {
1190
1189
  legends: legends,
1191
- hideLegend: (layout === null || layout === void 0 ? void 0 : layout.showlegend) === false || ((layout === null || layout === void 0 ? void 0 : layout.showlegend) !== true && legends.length < 2) ? true : hideLegends,
1190
+ hideLegend: isMultiPlot || hideLegendsInferred || hideLegendsData,
1192
1191
  };
1193
1192
  };
1194
1193
  var getNumberAtIndexOrDefault = function (data, index) {
@@ -1222,5 +1221,199 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
1222
1221
  return ranges;
1223
1222
  };
1224
1223
  exports.getValidXYRanges = getValidXYRanges;
1224
+ var getIndexFromKey = function (key, pattern) {
1225
+ var normalizedKey = key.replace(pattern, '') === '' ? '1' : key.replace(pattern, '');
1226
+ return parseInt(normalizedKey, 10) - 1;
1227
+ };
1228
+ var getGridProperties = function (layout, isMultiPlot) {
1229
+ var _a;
1230
+ var gridX = [];
1231
+ var gridY = [];
1232
+ var annotations = {};
1233
+ var templateRows = '1fr';
1234
+ var templateColumns = '1fr';
1235
+ var gridLayout = {};
1236
+ if (layout === undefined || layout === null || Object.keys(layout).length === 0) {
1237
+ return { templateRows: templateRows, templateColumns: templateColumns, layout: gridLayout };
1238
+ }
1239
+ if (!layout.xaxis || !layout.yaxis) {
1240
+ return { templateRows: templateRows, templateColumns: templateColumns, layout: gridLayout };
1241
+ }
1242
+ if (!isMultiPlot) {
1243
+ return { templateRows: templateRows, templateColumns: templateColumns, layout: gridLayout };
1244
+ }
1245
+ Object.keys(layout).forEach(function (key) {
1246
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1247
+ if (key.startsWith('xaxis')) {
1248
+ var index = getIndexFromKey(key, 'xaxis');
1249
+ var anchor = (_b = (_a = layout[key]) === null || _a === void 0 ? void 0 : _a.anchor) !== null && _b !== void 0 ? _b : 'y';
1250
+ var anchorIndex = getIndexFromKey(anchor, 'y');
1251
+ if (index !== anchorIndex) {
1252
+ throw new Error("Invalid layout: xaxis ".concat(index + 1, " anchor should be y").concat(anchorIndex + 1));
1253
+ }
1254
+ gridX[index] = (_d = (_c = layout[key]) === null || _c === void 0 ? void 0 : _c.domain) !== null && _d !== void 0 ? _d : [];
1255
+ }
1256
+ else if (key.startsWith('yaxis')) {
1257
+ var index = getIndexFromKey(key, 'yaxis');
1258
+ var anchor = (_f = (_e = layout[key]) === null || _e === void 0 ? void 0 : _e.anchor) !== null && _f !== void 0 ? _f : 'x';
1259
+ var anchorIndex = getIndexFromKey(anchor, 'x');
1260
+ if (index !== anchorIndex) {
1261
+ if ((index === 1 && anchorIndex === 0) || ((_g = layout.yaxis2) === null || _g === void 0 ? void 0 : _g.side) === 'right') {
1262
+ // Special case for secondary y axis where yaxis2 can anchor to x1
1263
+ return { templateRows: templateRows, templateColumns: templateColumns };
1264
+ }
1265
+ throw new Error("Invalid layout: yaxis ".concat(index + 1, " anchor should be x").concat(anchorIndex + 1));
1266
+ }
1267
+ gridY[index] = (_j = (_h = layout[key]) === null || _h === void 0 ? void 0 : _h.domain) !== null && _j !== void 0 ? _j : [];
1268
+ }
1269
+ });
1270
+ (_a = layout.annotations) === null || _a === void 0 ? void 0 : _a.forEach(function (annotation) {
1271
+ var xMatches = gridX.flatMap(function (interval, idx) {
1272
+ return (annotation === null || annotation === void 0 ? void 0 : annotation.x) >= interval[0] && (annotation === null || annotation === void 0 ? void 0 : annotation.x) <= interval[1] ? [idx] : [];
1273
+ });
1274
+ var yMatch = gridY.findIndex(function (interval, yIndex) {
1275
+ return xMatches.includes(yIndex) &&
1276
+ (annotation === null || annotation === void 0 ? void 0 : annotation.y) >= interval[0] &&
1277
+ (annotation === null || annotation === void 0 ? void 0 : annotation.y) <= interval[1];
1278
+ });
1279
+ if (yMatch !== -1) {
1280
+ if (annotations[yMatch] === undefined) {
1281
+ annotations[yMatch] = {};
1282
+ }
1283
+ if ((annotation === null || annotation === void 0 ? void 0 : annotation.textangle) === 90) {
1284
+ annotations[yMatch].yAnnotation = annotation.text;
1285
+ }
1286
+ else {
1287
+ annotations[yMatch].xAnnotation = annotation.text;
1288
+ }
1289
+ }
1290
+ });
1291
+ if (gridX.length > 0) {
1292
+ var uniqueXIntervals_1 = new Map();
1293
+ gridX.forEach(function (interval) {
1294
+ var key = "".concat(interval[0], "-").concat(interval[1]);
1295
+ if (!uniqueXIntervals_1.has(key)) {
1296
+ uniqueXIntervals_1.set(key, interval);
1297
+ }
1298
+ });
1299
+ var minXInterval_1 = Math.min.apply(Math, Array.from(uniqueXIntervals_1.values()).map(function (interval) { return interval[1] - interval[0]; }));
1300
+ templateColumns = Array.from(uniqueXIntervals_1.values())
1301
+ .map(function (interval) { return "".concat((interval[1] - interval[0]) / minXInterval_1, "fr"); })
1302
+ .join(' ');
1303
+ var columnNumber_1 = 1;
1304
+ var lastIntervalEnd_1 = 0;
1305
+ gridX.forEach(function (interval, index) {
1306
+ if (interval.length === 0) {
1307
+ return;
1308
+ }
1309
+ var cellName = "x".concat(index === 0 ? '' : index + 1);
1310
+ var annotationProps = annotations[index];
1311
+ var xAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.xAnnotation;
1312
+ if (interval[0] < lastIntervalEnd_1) {
1313
+ columnNumber_1 = 1;
1314
+ }
1315
+ lastIntervalEnd_1 = interval[1];
1316
+ var row = {
1317
+ row: -1,
1318
+ column: columnNumber_1,
1319
+ xAnnotation: xAnnotation,
1320
+ };
1321
+ gridLayout[cellName] = row;
1322
+ columnNumber_1 += 1;
1323
+ });
1324
+ }
1325
+ var numColumns = Math.max.apply(Math, Object.values(gridLayout).map(function (cell) { var _a; return (_a = cell.column) !== null && _a !== void 0 ? _a : 0; }));
1326
+ var columnFill = {};
1327
+ for (var i = 1; i <= numColumns; i++) {
1328
+ columnFill[i] = { row: 1, fillDomain: 0 };
1329
+ }
1330
+ if (gridY.length > 0) {
1331
+ var uniqueYIntervals_1 = new Map();
1332
+ gridY.forEach(function (interval) {
1333
+ var key = "".concat(interval[0], "-").concat(interval[1]);
1334
+ if (!uniqueYIntervals_1.has(key)) {
1335
+ uniqueYIntervals_1.set(key, interval);
1336
+ }
1337
+ });
1338
+ var minYInterval_1 = Math.min.apply(Math, Array.from(uniqueYIntervals_1.values()).map(function (interval) { return interval[1] - interval[0]; }));
1339
+ templateRows = Array.from(uniqueYIntervals_1.values())
1340
+ .map(function (interval) { return "".concat((interval[1] - interval[0]) / minYInterval_1, "fr"); })
1341
+ .join(' ');
1342
+ gridY.forEach(function (interval, index) {
1343
+ if (interval.length === 0) {
1344
+ return;
1345
+ }
1346
+ var cellName = "x".concat(index === 0 ? '' : index + 1);
1347
+ var annotationProps = annotations[index];
1348
+ var yAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.yAnnotation;
1349
+ var cell = gridLayout[cellName];
1350
+ if (cell !== undefined) {
1351
+ cell.row = columnFill[cell.column].row;
1352
+ cell.yAnnotation = yAnnotation;
1353
+ }
1354
+ columnFill[cell.column].fillDomain = interval[1];
1355
+ columnFill[cell.column].row += 1;
1356
+ });
1357
+ }
1358
+ // reverse the order of rows in grid layout from bottom-top to top-bottom as required by CSS grid
1359
+ var reversedGridLayout = {};
1360
+ // find the maximum row number
1361
+ var maxRowNumber = Math.max.apply(Math, Object.values(gridLayout).map(function (cell) { var _a; return (_a = cell.row) !== null && _a !== void 0 ? _a : 0; }));
1362
+ // iterate over the gridLayout and reverse the row numbers
1363
+ Object.keys(gridLayout).forEach(function (key) {
1364
+ var cell = gridLayout[key];
1365
+ if (cell.row !== undefined) {
1366
+ // reverse the row number
1367
+ cell.row = maxRowNumber - cell.row + 1;
1368
+ }
1369
+ reversedGridLayout[key] = cell;
1370
+ });
1371
+ return {
1372
+ templateRows: templateRows,
1373
+ templateColumns: templateColumns,
1374
+ layout: reversedGridLayout,
1375
+ };
1376
+ };
1377
+ exports.getGridProperties = getGridProperties;
1378
+ /**
1379
+ * @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/category_order_defaults.js#L50}
1380
+ */
1381
+ var getAxisCategoryOrderProps = function (data, layout) {
1382
+ var result = {};
1383
+ var axesById = {
1384
+ x: layout === null || layout === void 0 ? void 0 : layout.xaxis,
1385
+ y: layout === null || layout === void 0 ? void 0 : layout.yaxis,
1386
+ };
1387
+ Object.keys(axesById).forEach(function (axId) {
1388
+ var ax = axesById[axId];
1389
+ var axLetter = axId[0];
1390
+ var propName = "".concat(axLetter, "AxisCategoryOrder");
1391
+ var values = [];
1392
+ data.forEach(function (series) {
1393
+ var _a;
1394
+ (_a = series[axLetter]) === null || _a === void 0 ? void 0 : _a.forEach(function (val) {
1395
+ if (!(0, chart_utilities_1.isInvalidValue)(val)) {
1396
+ values.push(val);
1397
+ }
1398
+ });
1399
+ });
1400
+ var isAxisTypeCategory = (ax === null || ax === void 0 ? void 0 : ax.type) === 'category' || ((0, chart_utilities_1.isStringArray)(values) && !(0, chart_utilities_1.isNumberArray)(values) && !(0, chart_utilities_1.isDateArray)(values));
1401
+ if (!isAxisTypeCategory) {
1402
+ return;
1403
+ }
1404
+ var isValidArray = (0, chart_utilities_1.isArrayOrTypedArray)(ax === null || ax === void 0 ? void 0 : ax.categoryarray) && ax.categoryarray.length > 0;
1405
+ if (isValidArray && (!(ax === null || ax === void 0 ? void 0 : ax.categoryorder) || ax.categoryorder === 'array')) {
1406
+ result[propName] = ax.categoryarray;
1407
+ return;
1408
+ }
1409
+ if (!(ax === null || ax === void 0 ? void 0 : ax.categoryorder) || ax.categoryorder === 'trace' || ax.categoryorder === 'array') {
1410
+ var categoriesInTraceOrder = Array.from(new Set(values));
1411
+ result[propName] = categoriesInTraceOrder;
1412
+ return;
1413
+ }
1414
+ result[propName] = ax.categoryorder;
1415
+ });
1416
+ return result;
1417
+ };
1225
1418
  });
1226
1419
  //# sourceMappingURL=PlotlySchemaAdapter.js.map