@fluentui/react-charting 5.23.41 → 5.23.43

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 (114) hide show
  1. package/CHANGELOG.json +69 -1
  2. package/CHANGELOG.md +25 -2
  3. package/bundle-size/DeclarativeChart.fixture.js +7 -0
  4. package/dist/react-charting.d.ts +5 -0
  5. package/dist/react-charting.js +1 -1
  6. package/dist/react-charting.min.js +1 -1
  7. package/etc/react-charting.api.md +1 -0
  8. package/lib/Styling.js +3 -3
  9. package/lib/Styling.js.map +1 -1
  10. package/lib/Utilities.js +1 -19
  11. package/lib/Utilities.js.map +1 -1
  12. package/lib/components/AreaChart/AreaChart.base.d.ts +3 -3
  13. package/lib/components/AreaChart/AreaChart.base.js +53 -30
  14. package/lib/components/AreaChart/AreaChart.base.js.map +1 -1
  15. package/lib/components/AreaChart/AreaChart.types.d.ts +5 -0
  16. package/lib/components/AreaChart/AreaChart.types.js.map +1 -1
  17. package/lib/components/DeclarativeChart/DeclarativeChart.js +66 -49
  18. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  19. package/lib/components/DeclarativeChart/PlotlySchema.d.ts +1516 -0
  20. package/lib/components/DeclarativeChart/PlotlySchema.js +4 -0
  21. package/lib/components/DeclarativeChart/PlotlySchema.js.map +1 -0
  22. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +16 -13
  23. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +232 -118
  24. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  25. package/lib/components/DonutChart/DonutChart.base.js +3 -1
  26. package/lib/components/DonutChart/DonutChart.base.js.map +1 -1
  27. package/lib/components/HorizontalBarChart/HorizontalBarChart.base.js +3 -1
  28. package/lib/components/HorizontalBarChart/HorizontalBarChart.base.js.map +1 -1
  29. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +5 -4
  30. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
  31. package/lib/components/StackedBarChart/MultiStackedBarChart.base.js +3 -1
  32. package/lib/components/StackedBarChart/MultiStackedBarChart.base.js.map +1 -1
  33. package/lib/components/StackedBarChart/StackedBarChart.base.js +3 -1
  34. package/lib/components/StackedBarChart/StackedBarChart.base.js.map +1 -1
  35. package/lib/components/VerticalBarChart/VerticalBarChart.base.js +10 -1
  36. package/lib/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
  37. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +2 -2
  38. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
  39. package/lib/utilities/SVGTooltipText.js +1 -1
  40. package/lib/utilities/SVGTooltipText.js.map +1 -1
  41. package/lib/utilities/utilities.js +2 -9
  42. package/lib/utilities/utilities.js.map +1 -1
  43. package/lib-amd/Styling.js +3 -3
  44. package/lib-amd/Styling.js.map +1 -1
  45. package/lib-amd/Utilities.js +0 -9
  46. package/lib-amd/Utilities.js.map +1 -1
  47. package/lib-amd/components/AreaChart/AreaChart.base.d.ts +3 -3
  48. package/lib-amd/components/AreaChart/AreaChart.base.js +53 -30
  49. package/lib-amd/components/AreaChart/AreaChart.base.js.map +1 -1
  50. package/lib-amd/components/AreaChart/AreaChart.types.d.ts +5 -0
  51. package/lib-amd/components/AreaChart/AreaChart.types.js.map +1 -1
  52. package/lib-amd/components/DeclarativeChart/DeclarativeChart.js +64 -47
  53. package/lib-amd/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  54. package/lib-amd/components/DeclarativeChart/PlotlySchema.d.ts +1516 -0
  55. package/lib-amd/components/DeclarativeChart/PlotlySchema.js +7 -0
  56. package/lib-amd/components/DeclarativeChart/PlotlySchema.js.map +1 -0
  57. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +16 -13
  58. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +233 -119
  59. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  60. package/lib-amd/components/DonutChart/DonutChart.base.js +3 -1
  61. package/lib-amd/components/DonutChart/DonutChart.base.js.map +1 -1
  62. package/lib-amd/components/HorizontalBarChart/HorizontalBarChart.base.js +3 -1
  63. package/lib-amd/components/HorizontalBarChart/HorizontalBarChart.base.js.map +1 -1
  64. package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +5 -4
  65. package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
  66. package/lib-amd/components/StackedBarChart/MultiStackedBarChart.base.js +3 -1
  67. package/lib-amd/components/StackedBarChart/MultiStackedBarChart.base.js.map +1 -1
  68. package/lib-amd/components/StackedBarChart/StackedBarChart.base.js +3 -1
  69. package/lib-amd/components/StackedBarChart/StackedBarChart.base.js.map +1 -1
  70. package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js +10 -1
  71. package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
  72. package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +2 -2
  73. package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
  74. package/lib-amd/utilities/SVGTooltipText.js +1 -1
  75. package/lib-amd/utilities/SVGTooltipText.js.map +1 -1
  76. package/lib-amd/utilities/utilities.js +2 -9
  77. package/lib-amd/utilities/utilities.js.map +1 -1
  78. package/lib-commonjs/Styling.js +3 -3
  79. package/lib-commonjs/Styling.js.map +1 -1
  80. package/lib-commonjs/Utilities.js +0 -9
  81. package/lib-commonjs/Utilities.js.map +1 -1
  82. package/lib-commonjs/components/AreaChart/AreaChart.base.d.ts +3 -3
  83. package/lib-commonjs/components/AreaChart/AreaChart.base.js +53 -30
  84. package/lib-commonjs/components/AreaChart/AreaChart.base.js.map +1 -1
  85. package/lib-commonjs/components/AreaChart/AreaChart.types.d.ts +5 -0
  86. package/lib-commonjs/components/AreaChart/AreaChart.types.js.map +1 -1
  87. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +65 -48
  88. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  89. package/lib-commonjs/components/DeclarativeChart/PlotlySchema.d.ts +1516 -0
  90. package/lib-commonjs/components/DeclarativeChart/PlotlySchema.js +5 -0
  91. package/lib-commonjs/components/DeclarativeChart/PlotlySchema.js.map +1 -0
  92. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +16 -13
  93. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +233 -118
  94. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  95. package/lib-commonjs/components/DonutChart/DonutChart.base.js +3 -1
  96. package/lib-commonjs/components/DonutChart/DonutChart.base.js.map +1 -1
  97. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.base.js +3 -1
  98. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.base.js.map +1 -1
  99. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +5 -4
  100. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
  101. package/lib-commonjs/components/StackedBarChart/MultiStackedBarChart.base.js +3 -1
  102. package/lib-commonjs/components/StackedBarChart/MultiStackedBarChart.base.js.map +1 -1
  103. package/lib-commonjs/components/StackedBarChart/StackedBarChart.base.js +3 -1
  104. package/lib-commonjs/components/StackedBarChart/StackedBarChart.base.js.map +1 -1
  105. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js +10 -1
  106. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
  107. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +2 -2
  108. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
  109. package/lib-commonjs/utilities/SVGTooltipText.js +1 -1
  110. package/lib-commonjs/utilities/SVGTooltipText.js.map +1 -1
  111. package/lib-commonjs/utilities/utilities.js +2 -9
  112. package/lib-commonjs/utilities/utilities.js.map +1 -1
  113. package/package.json +1 -1
  114. package/src/components/AreaChart/AreaChart.types.ts +6 -0
@@ -1,42 +1,92 @@
1
- define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../../utilities/colors", "../GaugeChart/index"], function (require, exports, tslib_1, d3_array_1, d3_scale_1, d3_format_1, colors_1, index_1) {
1
+ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../../utilities/colors", "../GaugeChart/index", "d3-time-format"], function (require, exports, tslib_1, d3_array_1, d3_scale_1, d3_format_1, colors_1, index_1, d3_time_format_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.findArrayAttributes = exports.isArrayOrTypedArray = exports.sanitizeJson = exports.transformPlotlyJsonToGaugeProps = exports.transformPlotlyJsonToSankeyProps = exports.transformPlotlyJsonToHeatmapProps = exports.transformPlotlyJsonToHorizontalBarWithAxisProps = exports.transformPlotlyJsonToScatterChartProps = exports.transformPlotlyJsonToVBCProps = exports.transformPlotlyJsonToGVBCProps = exports.transformPlotlyJsonToVSBCProps = exports.transformPlotlyJsonToDonutProps = exports.getColor = exports.updateXValues = exports.isMonthArray = exports.isNumberArray = exports.isDateArray = void 0;
5
- var isDate = function (value) { return !isNaN(Date.parse(value)); };
4
+ exports.findArrayAttributes = exports.isArrayOrTypedArray = exports.sanitizeJson = exports.transformPlotlyJsonToGaugeProps = exports.transformPlotlyJsonToSankeyProps = exports.transformPlotlyJsonToHeatmapProps = exports.transformPlotlyJsonToHorizontalBarWithAxisProps = exports.transformPlotlyJsonToScatterChartProps = exports.transformPlotlyJsonToVBCProps = exports.transformPlotlyJsonToGVBCProps = exports.transformPlotlyJsonToVSBCProps = exports.transformPlotlyJsonToDonutProps = exports.getColor = exports.updateXValues = exports.isLineData = exports.isMonthArray = exports.isNumberArray = exports.isDateArray = void 0;
5
+ var SUPPORTED_PLOT_TYPES = ['pie', 'bar', 'scatter', 'heatmap', 'sankey', 'indicator', 'histogram'];
6
+ var isDate = function (value) {
7
+ var parsedDate = new Date(Date.parse(value));
8
+ if (isNaN(parsedDate.getTime())) {
9
+ return false;
10
+ }
11
+ var parsedYear = parsedDate.getFullYear();
12
+ var yearInString = /\b\d{4}\b/.test(value);
13
+ if (!yearInString && (parsedYear === 2000 || parsedYear === 2001)) {
14
+ return false;
15
+ }
16
+ return true;
17
+ };
6
18
  var isNumber = function (value) { return !isNaN(parseFloat(value)) && isFinite(value); };
7
- var isDateArray = function (array) { return isArrayOrTypedArray(array) && array.every(isDate); };
19
+ var isMonth = function (possiblyMonthValue) {
20
+ var parseFullMonth = (0, d3_time_format_1.timeParse)('%B');
21
+ var parseShortMonth = (0, d3_time_format_1.timeParse)('%b');
22
+ return parseFullMonth(possiblyMonthValue) !== null || parseShortMonth(possiblyMonthValue) !== null;
23
+ };
24
+ var isArrayOfType = function (plotCoordinates, typeCheck) {
25
+ var args = [];
26
+ for (var _i = 2; _i < arguments.length; _i++) {
27
+ args[_i - 2] = arguments[_i];
28
+ }
29
+ if (!isArrayOrTypedArray(plotCoordinates)) {
30
+ return false;
31
+ }
32
+ if (plotCoordinates.length === 0) {
33
+ return false;
34
+ }
35
+ if (Array.isArray(plotCoordinates[0])) {
36
+ // Handle 2D array
37
+ return plotCoordinates.every(function (innerArray) { return innerArray.every(function (datum) { return typeCheck.apply(void 0, tslib_1.__spreadArray([datum], args, false)); }); });
38
+ }
39
+ else {
40
+ // Handle 1D array
41
+ return plotCoordinates.every(function (datum) { return typeCheck.apply(void 0, tslib_1.__spreadArray([datum], args, false)); });
42
+ }
43
+ };
44
+ var isDateArray = function (data) {
45
+ return isArrayOfType(data, isDate);
46
+ };
8
47
  exports.isDateArray = isDateArray;
9
- var isNumberArray = function (array) { return isArrayOrTypedArray(array) && array.every(isNumber); };
48
+ var isNumberArray = function (data) {
49
+ return isArrayOfType(data, isNumber);
50
+ };
10
51
  exports.isNumberArray = isNumberArray;
11
- var isMonthArray = function (array) {
12
- if (array && array.length > 0) {
13
- var presentYear_1 = new Date().getFullYear();
14
- return array.every(function (possiblyMonthValue) {
15
- return isDate("".concat(possiblyMonthValue, " 01, ").concat(presentYear_1));
16
- });
17
- }
18
- return false;
52
+ var isMonthArray = function (data) {
53
+ return isArrayOfType(data, isMonth);
19
54
  };
20
55
  exports.isMonthArray = isMonthArray;
56
+ var isLineData = function (data) {
57
+ return (!SUPPORTED_PLOT_TYPES.includes("".concat(data.type)) &&
58
+ Array.isArray(data.x) &&
59
+ isArrayOfType(data.y, function (value) { return typeof value === 'number'; }) &&
60
+ data.x.length > 0 &&
61
+ data.x.length === data.y.length);
62
+ };
63
+ exports.isLineData = isLineData;
64
+ var invalidate2Dseries = function (series, chartType) {
65
+ var _a, _b;
66
+ if (((_a = series.x) === null || _a === void 0 ? void 0 : _a.length) > 0 && Array.isArray(series.x[0])) {
67
+ throw new Error("transform to ".concat(chartType, ":: 2D x array not supported"));
68
+ }
69
+ if (((_b = series.y) === null || _b === void 0 ? void 0 : _b.length) > 0 && Array.isArray(series.y[0])) {
70
+ throw new Error("transform to ".concat(chartType, ":: 2D y array not supported"));
71
+ }
72
+ };
73
+ var getLegend = function (series, index) {
74
+ return series.name || "Series ".concat(index + 1);
75
+ };
21
76
  function getTitles(layout) {
22
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
77
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
23
78
  var titles = {
24
- chartTitle: typeof layout.title === 'string' ? layout.title : typeof ((_a = layout.title) === null || _a === void 0 ? void 0 : _a.text) === 'string' ? layout.title.text : '',
25
- xAxisTitle: typeof ((_b = layout === null || layout === void 0 ? void 0 : layout.xaxis) === null || _b === void 0 ? void 0 : _b.title) === 'string'
26
- ? (_c = layout === null || layout === void 0 ? void 0 : layout.xaxis) === null || _c === void 0 ? void 0 : _c.title
27
- : typeof ((_e = (_d = layout === null || layout === void 0 ? void 0 : layout.xaxis) === null || _d === void 0 ? void 0 : _d.title) === null || _e === void 0 ? void 0 : _e.text) === 'string'
28
- ? (_g = (_f = layout === null || layout === void 0 ? void 0 : layout.xaxis) === null || _f === void 0 ? void 0 : _f.title) === null || _g === void 0 ? void 0 : _g.text
29
- : '',
30
- yAxisTitle: typeof ((_h = layout === null || layout === void 0 ? void 0 : layout.yaxis) === null || _h === void 0 ? void 0 : _h.title) === 'string'
31
- ? (_j = layout === null || layout === void 0 ? void 0 : layout.yaxis) === null || _j === void 0 ? void 0 : _j.title
32
- : typeof ((_l = (_k = layout === null || layout === void 0 ? void 0 : layout.yaxis) === null || _k === void 0 ? void 0 : _k.title) === null || _l === void 0 ? void 0 : _l.text) === 'string'
33
- ? (_o = (_m = layout === null || layout === void 0 ? void 0 : layout.yaxis) === null || _m === void 0 ? void 0 : _m.title) === null || _o === void 0 ? void 0 : _o.text
34
- : '',
79
+ chartTitle: typeof (layout === null || layout === void 0 ? void 0 : layout.title) === 'string' ? layout.title : (_b = (_a = layout === null || layout === void 0 ? void 0 : layout.title) === null || _a === void 0 ? void 0 : _a.text) !== null && _b !== void 0 ? _b : '',
80
+ xAxisTitle: typeof ((_c = layout === null || layout === void 0 ? void 0 : layout.xaxis) === null || _c === void 0 ? void 0 : _c.title) === 'string' ? (_d = layout === null || layout === void 0 ? void 0 : layout.xaxis) === null || _d === void 0 ? void 0 : _d.title : (_g = (_f = (_e = layout === null || layout === void 0 ? void 0 : layout.xaxis) === null || _e === void 0 ? void 0 : _e.title) === null || _f === void 0 ? void 0 : _f.text) !== null && _g !== void 0 ? _g : '',
81
+ yAxisTitle: typeof ((_h = layout === null || layout === void 0 ? void 0 : layout.yaxis) === null || _h === void 0 ? void 0 : _h.title) === 'string' ? (_j = layout === null || layout === void 0 ? void 0 : layout.yaxis) === null || _j === void 0 ? void 0 : _j.title : (_m = (_l = (_k = layout === null || layout === void 0 ? void 0 : layout.yaxis) === null || _k === void 0 ? void 0 : _k.title) === null || _l === void 0 ? void 0 : _l.text) !== null && _m !== void 0 ? _m : '',
35
82
  };
36
83
  return titles;
37
84
  }
38
85
  var updateXValues = function (xValues) {
39
86
  var presentYear = new Date().getFullYear();
87
+ if (xValues.length > 0 && Array.isArray(xValues[0])) {
88
+ throw new Error('updateXValues:: 2D array not supported');
89
+ }
40
90
  var dates = xValues.map(function (possiblyMonthValue) {
41
91
  var parsedDate = "".concat(possiblyMonthValue, " 01, ").concat(presentYear);
42
92
  return isDate(parsedDate) ? new Date(parsedDate) : null;
@@ -68,21 +118,54 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
68
118
  return colorMap.current.get(legendLabel);
69
119
  };
70
120
  exports.getColor = getColor;
71
- var transformPlotlyJsonToDonutProps = function (jsonObj, colorMap, isDarkTheme) {
72
- var _a, _b;
73
- var data = jsonObj.data, layout = jsonObj.layout;
74
- var firstData = data[0];
121
+ var getSecondaryYAxisValues = function (series, layout) {
122
+ var _a;
123
+ var secondaryYAxisValues = {};
124
+ if (layout && layout.yaxis2 && series.yaxis === 'y2') {
125
+ secondaryYAxisValues.secondaryYAxistitle =
126
+ typeof layout.yaxis2.title === 'string'
127
+ ? layout.yaxis2.title
128
+ : typeof ((_a = layout.yaxis2.title) === null || _a === void 0 ? void 0 : _a.text) === 'string'
129
+ ? layout.yaxis2.title.text
130
+ : '';
131
+ if (layout.yaxis2.range) {
132
+ secondaryYAxisValues.secondaryYScaleOptions = {
133
+ yMinValue: layout.yaxis2.range[0],
134
+ yMaxValue: layout.yaxis2.range[1],
135
+ };
136
+ }
137
+ else {
138
+ var yValues = series.y;
139
+ if (yValues) {
140
+ secondaryYAxisValues.secondaryYScaleOptions = {
141
+ yMinValue: Math.min.apply(Math, yValues),
142
+ yMaxValue: Math.max.apply(Math, yValues),
143
+ };
144
+ }
145
+ }
146
+ }
147
+ secondaryYAxisValues.secondaryYAxistitle =
148
+ secondaryYAxisValues.secondaryYAxistitle !== '' ? secondaryYAxisValues.secondaryYAxistitle : undefined;
149
+ secondaryYAxisValues.secondaryYScaleOptions =
150
+ secondaryYAxisValues.secondaryYScaleOptions && Object.keys(secondaryYAxisValues.secondaryYScaleOptions).length !== 0
151
+ ? secondaryYAxisValues.secondaryYScaleOptions
152
+ : undefined;
153
+ return secondaryYAxisValues;
154
+ };
155
+ var transformPlotlyJsonToDonutProps = function (input, colorMap, isDarkTheme) {
156
+ var _a, _b, _c, _d, _e, _f, _g;
157
+ var firstData = input.data[0];
75
158
  var donutData = (_a = firstData.labels) === null || _a === void 0 ? void 0 : _a.map(function (label, index) {
76
159
  var _a;
77
160
  var color = (0, exports.getColor)(label, colorMap, isDarkTheme);
78
161
  return {
79
162
  legend: label,
80
- data: (_a = firstData.values) === null || _a === void 0 ? void 0 : _a[index],
163
+ data: (_a = firstData.values) === null || _a === void 0 ? void 0 : _a[index], //ToDo how to handle string data?
81
164
  color: color,
82
165
  };
83
166
  });
84
- var width = typeof (layout === null || layout === void 0 ? void 0 : layout.width) === 'number' ? layout === null || layout === void 0 ? void 0 : layout.width : 440;
85
- var height = typeof (layout === null || layout === void 0 ? void 0 : layout.height) === 'number' ? layout === null || layout === void 0 ? void 0 : layout.height : 220;
167
+ var width = (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.width) !== null && _c !== void 0 ? _c : 440;
168
+ var height = (_e = (_d = input.layout) === null || _d === void 0 ? void 0 : _d.height) !== null && _e !== void 0 ? _e : 220;
86
169
  var hideLabels = firstData.textinfo
87
170
  ? !['value', 'percent', 'label+percent'].includes(firstData.textinfo)
88
171
  : false;
@@ -93,57 +176,63 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
93
176
  : 0;
94
177
  var styles = {
95
178
  root: {
96
- '[class^="arcLabel"]': tslib_1.__assign({}, (typeof ((_b = firstData.textfont) === null || _b === void 0 ? void 0 : _b.size) === 'number' ? { fontSize: firstData.textfont.size } : {})),
179
+ '[class^="arcLabel"]': tslib_1.__assign({}, (typeof ((_f = firstData.textfont) === null || _f === void 0 ? void 0 : _f.size) === 'number' ? { fontSize: firstData.textfont.size } : {})),
97
180
  },
98
181
  };
99
- var chartTitle = getTitles(layout).chartTitle;
182
+ var chartTitle = getTitles(input.layout).chartTitle;
100
183
  return {
101
184
  data: {
102
185
  chartTitle: chartTitle,
103
186
  chartData: donutData,
104
187
  },
105
- hideLegend: (layout === null || layout === void 0 ? void 0 : layout.showlegend) === false ? true : false,
188
+ hideLegend: ((_g = input.layout) === null || _g === void 0 ? void 0 : _g.showlegend) === false ? true : false,
106
189
  width: width,
107
190
  height: height,
108
191
  innerRadius: innerRadius,
109
192
  hideLabels: hideLabels,
110
- showLabelsInPercent: firstData.textinfo ? firstData.textinfo === 'percent' : true,
193
+ showLabelsInPercent: firstData.textinfo ? ['percent', 'label+percent'].includes(firstData.textinfo) : true,
111
194
  styles: styles,
112
195
  };
113
196
  };
114
197
  exports.transformPlotlyJsonToDonutProps = transformPlotlyJsonToDonutProps;
115
- var transformPlotlyJsonToVSBCProps = function (jsonObj, colorMap, isDarkTheme) {
116
- var data = jsonObj.data, layout = jsonObj.layout;
198
+ var transformPlotlyJsonToVSBCProps = function (input, colorMap, isDarkTheme, fallbackVSBC) {
117
199
  var mapXToDataPoints = {};
118
200
  var yMaxValue = 0;
119
- data.forEach(function (series, index1) {
201
+ var secondaryYAxisValues = {};
202
+ input.data.forEach(function (series, index1) {
120
203
  var _a;
204
+ invalidate2Dseries(series, 'VSBC');
205
+ if (!(0, exports.isNumberArray)(series.y)) {
206
+ throw new Error('transform to VSBC:: y values should be numeric');
207
+ }
121
208
  (_a = series.x) === null || _a === void 0 ? void 0 : _a.forEach(function (x, index2) {
122
- var _a, _b, _c;
209
+ var _a, _b;
123
210
  if (!mapXToDataPoints[x]) {
124
211
  mapXToDataPoints[x] = { xAxisPoint: x, chartData: [], lineData: [] };
125
212
  }
126
- var legend = series.name || "Series ".concat(index1 + 1);
127
- if (series.type === 'bar' || series.type === 'scatter') {
213
+ var legend = getLegend(series, index1);
214
+ var yVal = (_b = (_a = series.y) === null || _a === void 0 ? void 0 : _a[index2]) !== null && _b !== void 0 ? _b : 0;
215
+ if (series.type === 'bar') {
128
216
  var color = (0, exports.getColor)(legend, colorMap, isDarkTheme);
129
217
  mapXToDataPoints[x].chartData.push({
130
218
  legend: legend,
131
- data: (_a = series.y) === null || _a === void 0 ? void 0 : _a[index2],
219
+ data: yVal,
132
220
  color: color,
133
221
  });
134
222
  }
135
- else if (series.type === 'line') {
223
+ else if (series.type === 'scatter' || (0, exports.isLineData)(series) || !!fallbackVSBC) {
136
224
  var color = (0, exports.getColor)(legend, colorMap, isDarkTheme);
137
225
  mapXToDataPoints[x].lineData.push({
138
226
  legend: legend,
139
- y: (_b = series.y) === null || _b === void 0 ? void 0 : _b[index2],
227
+ y: yVal,
140
228
  color: color,
141
229
  });
142
230
  }
143
- yMaxValue = Math.max(yMaxValue, (_c = series.y) === null || _c === void 0 ? void 0 : _c[index2]);
231
+ yMaxValue = Math.max(yMaxValue, yVal);
144
232
  });
233
+ secondaryYAxisValues = getSecondaryYAxisValues(series, input.layout);
145
234
  });
146
- var _a = getTitles(layout), chartTitle = _a.chartTitle, xAxisTitle = _a.xAxisTitle, yAxisTitle = _a.yAxisTitle;
235
+ var _a = getTitles(input.layout), chartTitle = _a.chartTitle, xAxisTitle = _a.xAxisTitle, yAxisTitle = _a.yAxisTitle;
147
236
  return {
148
237
  data: Object.values(mapXToDataPoints),
149
238
  // width: layout?.width,
@@ -154,33 +243,40 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
154
243
  xAxisTitle: xAxisTitle,
155
244
  yAxisTitle: yAxisTitle,
156
245
  mode: 'plotly',
246
+ secondaryYAxistitle: secondaryYAxisValues.secondaryYAxistitle,
247
+ secondaryYScaleOptions: secondaryYAxisValues.secondaryYScaleOptions,
157
248
  };
158
249
  };
159
250
  exports.transformPlotlyJsonToVSBCProps = transformPlotlyJsonToVSBCProps;
160
- var transformPlotlyJsonToGVBCProps = function (jsonObj, colorMap, isDarkTheme) {
161
- var data = jsonObj.data, layout = jsonObj.layout;
251
+ var transformPlotlyJsonToGVBCProps = function (input, colorMap, isDarkTheme) {
162
252
  var mapXToDataPoints = {};
163
- data.forEach(function (series, index1) {
253
+ var secondaryYAxisValues = {};
254
+ input.data.forEach(function (series, index1) {
164
255
  var _a;
256
+ invalidate2Dseries(series, 'GVBC');
257
+ if (!(0, exports.isNumberArray)(series.y)) {
258
+ throw new Error('transform to GVBC:: y values should be numeric');
259
+ }
165
260
  (_a = series.x) === null || _a === void 0 ? void 0 : _a.forEach(function (x, index2) {
166
- var _a;
261
+ var _a, _b;
167
262
  if (!mapXToDataPoints[x]) {
168
263
  mapXToDataPoints[x] = { name: x.toString(), series: [] };
169
264
  }
170
265
  if (series.type === 'bar') {
171
- var legend = series.name || "Series ".concat(index1 + 1);
266
+ var legend = getLegend(series, index1);
172
267
  var color = (0, exports.getColor)(legend, colorMap, isDarkTheme);
173
268
  mapXToDataPoints[x].series.push({
174
269
  key: legend,
175
- data: (_a = series.y) === null || _a === void 0 ? void 0 : _a[index2],
270
+ data: (_b = (_a = series.y) === null || _a === void 0 ? void 0 : _a[index2]) !== null && _b !== void 0 ? _b : 0,
176
271
  xAxisCalloutData: x,
177
272
  color: color,
178
273
  legend: legend,
179
274
  });
180
275
  }
181
276
  });
277
+ secondaryYAxisValues = getSecondaryYAxisValues(series, input.layout);
182
278
  });
183
- var _a = getTitles(layout), chartTitle = _a.chartTitle, xAxisTitle = _a.xAxisTitle, yAxisTitle = _a.yAxisTitle;
279
+ var _a = getTitles(input.layout), chartTitle = _a.chartTitle, xAxisTitle = _a.xAxisTitle, yAxisTitle = _a.yAxisTitle;
184
280
  return {
185
281
  data: Object.values(mapXToDataPoints),
186
282
  // width: layout?.width,
@@ -190,14 +286,16 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
190
286
  xAxisTitle: xAxisTitle,
191
287
  yAxisTitle: yAxisTitle,
192
288
  mode: 'plotly',
289
+ secondaryYAxistitle: secondaryYAxisValues.secondaryYAxistitle,
290
+ secondaryYScaleOptions: secondaryYAxisValues.secondaryYScaleOptions,
193
291
  };
194
292
  };
195
293
  exports.transformPlotlyJsonToGVBCProps = transformPlotlyJsonToGVBCProps;
196
- var transformPlotlyJsonToVBCProps = function (jsonObj, colorMap, isDarkTheme) {
197
- var data = jsonObj.data, layout = jsonObj.layout;
294
+ var transformPlotlyJsonToVBCProps = function (input, colorMap, isDarkTheme) {
198
295
  var vbcData = [];
199
- data.forEach(function (series, index) {
296
+ input.data.forEach(function (series, index) {
200
297
  var _a, _b, _c;
298
+ invalidate2Dseries(series, 'VBC');
201
299
  if (!series.x) {
202
300
  return;
203
301
  }
@@ -225,7 +323,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
225
323
  // If the start or end of xbins is specified, then the number of datapoints may become less than x.length
226
324
  var totalDataPoints = (0, d3_array_1.merge)(buckets).length;
227
325
  buckets.forEach(function (bucket) {
228
- var legend = series.name || "Series ".concat(index + 1);
326
+ var legend = getLegend(series, index);
229
327
  var color = (0, exports.getColor)(legend, colorMap, isDarkTheme);
230
328
  var y = bucket.length;
231
329
  if (series.histnorm === 'percent') {
@@ -261,12 +359,11 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
261
359
  });
262
360
  });
263
361
  });
264
- var _a = getTitles(layout), chartTitle = _a.chartTitle, xAxisTitle = _a.xAxisTitle, yAxisTitle = _a.yAxisTitle;
362
+ var _a = getTitles(input.layout), chartTitle = _a.chartTitle, xAxisTitle = _a.xAxisTitle, yAxisTitle = _a.yAxisTitle;
265
363
  return {
266
364
  data: vbcData,
267
365
  // width: layout?.width,
268
366
  // height: layout?.height,
269
- barWidth: 24,
270
367
  supportNegativeData: true,
271
368
  chartTitle: chartTitle,
272
369
  xAxisTitle: xAxisTitle,
@@ -275,15 +372,19 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
275
372
  };
276
373
  };
277
374
  exports.transformPlotlyJsonToVBCProps = transformPlotlyJsonToVBCProps;
278
- var transformPlotlyJsonToScatterChartProps = function (jsonObj, isAreaChart, colorMap, isDarkTheme) {
279
- var data = jsonObj.data, layout = jsonObj.layout;
280
- var chartData = data.map(function (series, index) {
375
+ var transformPlotlyJsonToScatterChartProps = function (input, isAreaChart, colorMap, isDarkTheme) {
376
+ var secondaryYAxisValues = {};
377
+ var mode = 'tonexty';
378
+ var chartData = input.data.map(function (series, index) {
379
+ invalidate2Dseries(series, 'Scatter');
281
380
  var xValues = series.x;
282
381
  var isString = typeof xValues[0] === 'string';
283
382
  var isXDate = (0, exports.isDateArray)(xValues);
284
383
  var isXNumber = (0, exports.isNumberArray)(xValues);
285
- var legend = series.name || "Series ".concat(index + 1);
384
+ var legend = getLegend(series, index);
286
385
  var lineColor = (0, exports.getColor)(legend, colorMap, isDarkTheme);
386
+ secondaryYAxisValues = getSecondaryYAxisValues(series, input.layout);
387
+ mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
287
388
  return {
288
389
  legend: legend,
289
390
  data: xValues.map(function (x, i) { return ({
@@ -293,7 +394,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
293
394
  color: lineColor,
294
395
  };
295
396
  });
296
- var _a = getTitles(layout), chartTitle = _a.chartTitle, xAxisTitle = _a.xAxisTitle, yAxisTitle = _a.yAxisTitle;
397
+ var _a = getTitles(input.layout), chartTitle = _a.chartTitle, xAxisTitle = _a.xAxisTitle, yAxisTitle = _a.yAxisTitle;
297
398
  var chartProps = {
298
399
  chartTitle: chartTitle,
299
400
  lineChartData: chartData,
@@ -304,6 +405,9 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
304
405
  supportNegativeData: true,
305
406
  xAxisTitle: xAxisTitle,
306
407
  yAxisTitle: yAxisTitle,
408
+ secondaryYAxistitle: secondaryYAxisValues.secondaryYAxistitle,
409
+ secondaryYScaleOptions: secondaryYAxisValues.secondaryYScaleOptions,
410
+ mode: mode,
307
411
  };
308
412
  }
309
413
  else {
@@ -312,15 +416,17 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
312
416
  supportNegativeData: true,
313
417
  xAxisTitle: xAxisTitle,
314
418
  yAxisTitle: yAxisTitle,
419
+ secondaryYAxistitle: secondaryYAxisValues.secondaryYAxistitle,
420
+ secondaryYScaleOptions: secondaryYAxisValues.secondaryYScaleOptions,
315
421
  };
316
422
  }
317
423
  };
318
424
  exports.transformPlotlyJsonToScatterChartProps = transformPlotlyJsonToScatterChartProps;
319
- var transformPlotlyJsonToHorizontalBarWithAxisProps = function (jsonObj, colorMap, isDarkTheme) {
320
- var _a, _b, _c, _d, _e, _f, _g, _h;
321
- var data = jsonObj.data, layout = jsonObj.layout;
322
- var chartData = data
425
+ var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, colorMap, isDarkTheme) {
426
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
427
+ var chartData = input.data
323
428
  .map(function (series, index) {
429
+ invalidate2Dseries(series, 'HBC');
324
430
  return series.y.map(function (yValue, i) {
325
431
  var color = (0, exports.getColor)(yValue, colorMap, isDarkTheme);
326
432
  return {
@@ -331,48 +437,51 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
331
437
  };
332
438
  });
333
439
  })
334
- .flat();
335
- var chartHeight = typeof layout.height === 'number' ? layout.height : 450;
336
- var margin = typeof ((_a = layout.margin) === null || _a === void 0 ? void 0 : _a.l) === 'number' ? (_b = layout.margin) === null || _b === void 0 ? void 0 : _b.l : 0;
337
- var padding = typeof ((_c = layout.margin) === null || _c === void 0 ? void 0 : _c.pad) === 'number' ? (_d = layout.margin) === null || _d === void 0 ? void 0 : _d.pad : 0;
440
+ .flat()
441
+ //reversing the order to invert the Y bars order as required by plotly.
442
+ .reverse();
443
+ var chartHeight = (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.height) !== null && _b !== void 0 ? _b : 450;
444
+ 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;
445
+ 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;
338
446
  var availableHeight = chartHeight - margin - padding;
339
- var numberOfBars = data[0].y.length;
447
+ var numberOfBars = input.data[0].y.length;
340
448
  var scalingFactor = 0.01;
341
449
  var gapFactor = 1 / (1 + scalingFactor * numberOfBars);
342
450
  var barHeight = availableHeight / (numberOfBars * (1 + gapFactor));
343
- var _j = getTitles(layout), chartTitle = _j.chartTitle, xAxisTitle = _j.xAxisTitle, yAxisTitle = _j.yAxisTitle;
451
+ var _t = getTitles(input.layout), chartTitle = _t.chartTitle, xAxisTitle = _t.xAxisTitle, yAxisTitle = _t.yAxisTitle;
344
452
  return {
345
453
  data: chartData,
346
454
  chartTitle: chartTitle,
347
455
  xAxisTitle: xAxisTitle,
348
456
  yAxisTitle: yAxisTitle,
349
- secondaryYAxistitle: typeof ((_e = layout === null || layout === void 0 ? void 0 : layout.yaxis2) === null || _e === void 0 ? void 0 : _e.title) === 'string' ? (_f = layout === null || layout === void 0 ? void 0 : layout.yaxis2) === null || _f === void 0 ? void 0 : _f.title : ((_h = (_g = layout === null || layout === void 0 ? void 0 : layout.yaxis2) === null || _g === void 0 ? void 0 : _g.title) === null || _h === void 0 ? void 0 : _h.text) || '',
457
+ secondaryYAxistitle: typeof ((_k = (_j = input.layout) === null || _j === void 0 ? void 0 : _j.yaxis2) === null || _k === void 0 ? void 0 : _k.title) === 'string'
458
+ ? (_m = (_l = input.layout) === null || _l === void 0 ? void 0 : _l.yaxis2) === null || _m === void 0 ? void 0 : _m.title
459
+ : ((_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) || '',
350
460
  barHeight: barHeight,
351
461
  showYAxisLables: true,
352
462
  styles: {
353
463
  root: {
354
464
  height: chartHeight,
355
- width: typeof layout.width === 'number' ? layout.width : 600,
465
+ width: (_s = (_r = input.layout) === null || _r === void 0 ? void 0 : _r.width) !== null && _s !== void 0 ? _s : 600,
356
466
  },
357
467
  },
358
468
  };
359
469
  };
360
470
  exports.transformPlotlyJsonToHorizontalBarWithAxisProps = transformPlotlyJsonToHorizontalBarWithAxisProps;
361
- var transformPlotlyJsonToHeatmapProps = function (jsonObj) {
471
+ var transformPlotlyJsonToHeatmapProps = function (input) {
362
472
  var _a;
363
- var data = jsonObj.data, layout = jsonObj.layout;
364
- var firstData = data[0];
473
+ var firstData = input.data[0];
365
474
  var heatmapDataPoints = [];
366
475
  var zMin = Number.POSITIVE_INFINITY;
367
476
  var zMax = Number.NEGATIVE_INFINITY;
368
477
  (_a = firstData.x) === null || _a === void 0 ? void 0 : _a.forEach(function (xVal, xIdx) {
369
478
  var _a;
370
479
  (_a = firstData.y) === null || _a === void 0 ? void 0 : _a.forEach(function (yVal, yIdx) {
371
- var _a, _b, _c, _d;
480
+ var _a, _b, _c, _d, _e, _f;
372
481
  var zVal = (_b = (_a = firstData.z) === null || _a === void 0 ? void 0 : _a[yIdx]) === null || _b === void 0 ? void 0 : _b[xIdx];
373
482
  heatmapDataPoints.push({
374
- x: ((_c = layout.xaxis) === null || _c === void 0 ? void 0 : _c.type) === 'date' ? new Date(xVal) : xVal,
375
- y: ((_d = layout.yaxis) === null || _d === void 0 ? void 0 : _d.type) === 'date' ? new Date(yVal) : yVal,
483
+ x: ((_d = (_c = input.layout) === null || _c === void 0 ? void 0 : _c.xaxis) === null || _d === void 0 ? void 0 : _d.type) === 'date' ? xVal : xVal !== null && xVal !== void 0 ? xVal : 0,
484
+ y: ((_f = (_e = input.layout) === null || _e === void 0 ? void 0 : _e.yaxis) === null || _f === void 0 ? void 0 : _f.type) === 'date' ? yVal : yVal,
376
485
  value: zVal,
377
486
  rectText: zVal,
378
487
  });
@@ -381,16 +490,24 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
381
490
  });
382
491
  });
383
492
  var heatmapData = {
384
- legend: typeof firstData.name === 'string' ? firstData.name : '',
493
+ legend: firstData.name,
385
494
  data: heatmapDataPoints,
386
495
  value: 0,
387
496
  };
388
- // Convert normalized values to actual values
389
- var domainValuesForColorScale = firstData.colorscale
497
+ // Initialize domain and range to default values
498
+ var defaultDomain = [zMin, zMax];
499
+ var defaultRange = [
500
+ (0, colors_1.getColorFromToken)(colors_1.DataVizPalette.color1),
501
+ (0, colors_1.getColorFromToken)(colors_1.DataVizPalette.color2),
502
+ (0, colors_1.getColorFromToken)(colors_1.DataVizPalette.color3),
503
+ ];
504
+ var domainValuesForColorScale = Array.isArray(firstData.colorscale)
390
505
  ? firstData.colorscale.map(function (arr) { return arr[0] * (zMax - zMin) + zMin; })
391
- : [];
392
- var rangeValuesForColorScale = firstData.colorscale ? firstData.colorscale.map(function (arr) { return arr[1]; }) : [];
393
- var _b = getTitles(layout), chartTitle = _b.chartTitle, xAxisTitle = _b.xAxisTitle, yAxisTitle = _b.yAxisTitle;
506
+ : defaultDomain;
507
+ var rangeValuesForColorScale = Array.isArray(firstData.colorscale)
508
+ ? firstData.colorscale.map(function (arr) { return arr[1]; })
509
+ : defaultRange;
510
+ var _b = getTitles(input.layout), chartTitle = _b.chartTitle, xAxisTitle = _b.xAxisTitle, yAxisTitle = _b.yAxisTitle;
394
511
  return {
395
512
  data: [heatmapData],
396
513
  domainValuesForColorScale: domainValuesForColorScale,
@@ -404,22 +521,20 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
404
521
  };
405
522
  };
406
523
  exports.transformPlotlyJsonToHeatmapProps = transformPlotlyJsonToHeatmapProps;
407
- var transformPlotlyJsonToSankeyProps = function (jsonObj, colorMap, isDarkTheme) {
408
- var _a, _b;
409
- var data = jsonObj.data, layout = jsonObj.layout;
410
- var _c = data[0], link = _c.link, node = _c.node;
411
- var validLinks = link.value
524
+ var transformPlotlyJsonToSankeyProps = function (input, colorMap, isDarkTheme) {
525
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
526
+ var _k = input.data[0], link = _k.link, node = _k.node;
527
+ var validLinks = ((_a = link === null || link === void 0 ? void 0 : link.value) !== null && _a !== void 0 ? _a : [])
412
528
  .map(function (val, index) { return ({
413
529
  value: val,
414
- source: link.source[index],
415
- target: link.target[index],
530
+ source: link === null || link === void 0 ? void 0 : link.source[index],
531
+ target: link === null || link === void 0 ? void 0 : link.target[index],
416
532
  }); })
417
533
  // eslint-disable-next-line @typescript-eslint/no-shadow
418
- //@ts-expect-error Dynamic link object. Ignore for now.
419
534
  // Filter out negative nodes, unequal nodes and self-references (circular links)
420
535
  .filter(function (x) { return x.source >= 0 && x.target >= 0 && x.source !== x.target; });
421
536
  var sankeyChartData = {
422
- nodes: node.label.map(function (label, index) {
537
+ nodes: (_b = node.label) === null || _b === void 0 ? void 0 : _b.map(function (label, index) {
423
538
  var color = (0, exports.getColor)(label, colorMap, isDarkTheme);
424
539
  return {
425
540
  nodeId: index,
@@ -431,13 +546,13 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
431
546
  return tslib_1.__assign({}, validLink);
432
547
  }),
433
548
  };
434
- var width = typeof (layout === null || layout === void 0 ? void 0 : layout.width) === 'number' ? layout === null || layout === void 0 ? void 0 : layout.width : 440;
435
- var height = typeof (layout === null || layout === void 0 ? void 0 : layout.height) === 'number' ? layout === null || layout === void 0 ? void 0 : layout.height : 220;
549
+ var width = (_d = (_c = input.layout) === null || _c === void 0 ? void 0 : _c.width) !== null && _d !== void 0 ? _d : 440;
550
+ var height = (_f = (_e = input.layout) === null || _e === void 0 ? void 0 : _e.height) !== null && _f !== void 0 ? _f : 220;
436
551
  var styles = {
437
- root: tslib_1.__assign({}, (typeof ((_a = layout.font) === null || _a === void 0 ? void 0 : _a.size) === 'number' ? { fontSize: (_b = layout.font) === null || _b === void 0 ? void 0 : _b.size } : {})),
552
+ root: tslib_1.__assign({}, (((_h = (_g = input.layout) === null || _g === void 0 ? void 0 : _g.font) === null || _h === void 0 ? void 0 : _h.size) ? { fontSize: (_j = input.layout.font) === null || _j === void 0 ? void 0 : _j.size } : {})),
438
553
  };
439
554
  var shouldResize = width + height;
440
- var chartTitle = getTitles(layout).chartTitle;
555
+ var chartTitle = getTitles(input.layout).chartTitle;
441
556
  return {
442
557
  data: {
443
558
  chartTitle: chartTitle,
@@ -451,10 +566,9 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
451
566
  };
452
567
  };
453
568
  exports.transformPlotlyJsonToSankeyProps = transformPlotlyJsonToSankeyProps;
454
- var transformPlotlyJsonToGaugeProps = function (jsonObj, colorMap, isDarkTheme) {
455
- 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;
456
- var data = jsonObj.data, layout = jsonObj.layout;
457
- var firstData = data[0];
569
+ var transformPlotlyJsonToGaugeProps = function (input, colorMap, isDarkTheme) {
570
+ 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;
571
+ var firstData = input.data[0];
458
572
  var segments = ((_b = (_a = firstData.gauge) === null || _a === void 0 ? void 0 : _a.steps) === null || _b === void 0 ? void 0 : _b.length)
459
573
  ? firstData.gauge.steps.map(function (step, index) {
460
574
  var _a, _b;
@@ -469,27 +583,27 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
469
583
  : [
470
584
  {
471
585
  legend: 'Current',
472
- size: (_c = firstData.value) !== null && _c !== void 0 ? _c : 0 - ((_f = (_e = (_d = firstData.gauge) === null || _d === void 0 ? void 0 : _d.range) === null || _e === void 0 ? void 0 : _e[0]) !== null && _f !== void 0 ? _f : 0),
586
+ size: (_c = firstData.value) !== null && _c !== void 0 ? _c : 0 - ((_g = (_f = (_e = (_d = firstData.gauge) === null || _d === void 0 ? void 0 : _d.axis) === null || _e === void 0 ? void 0 : _e.range) === null || _f === void 0 ? void 0 : _f[0]) !== null && _g !== void 0 ? _g : 0),
473
587
  color: (0, exports.getColor)('Current', colorMap, isDarkTheme),
474
588
  },
475
589
  {
476
590
  legend: 'Target',
477
- size: ((_j = (_h = (_g = firstData.gauge) === null || _g === void 0 ? void 0 : _g.range) === null || _h === void 0 ? void 0 : _h[1]) !== null && _j !== void 0 ? _j : 100) - ((_k = firstData.value) !== null && _k !== void 0 ? _k : 0),
591
+ size: ((_l = (_k = (_j = (_h = firstData.gauge) === null || _h === void 0 ? void 0 : _h.axis) === null || _j === void 0 ? void 0 : _j.range) === null || _k === void 0 ? void 0 : _k[1]) !== null && _l !== void 0 ? _l : 100) - ((_m = firstData.value) !== null && _m !== void 0 ? _m : 0),
478
592
  color: colors_1.DataVizPalette.disabled,
479
593
  },
480
594
  ];
481
595
  var sublabel;
482
596
  var sublabelColor;
483
- if (typeof ((_l = firstData.delta) === null || _l === void 0 ? void 0 : _l.reference) === 'number') {
597
+ if ((_o = firstData.delta) === null || _o === void 0 ? void 0 : _o.reference) {
484
598
  var diff = firstData.value - firstData.delta.reference;
485
599
  if (diff >= 0) {
486
600
  sublabel = "\u25B2 ".concat(diff);
487
- var color = (0, exports.getColor)(((_m = firstData.delta.increasing) === null || _m === void 0 ? void 0 : _m.color) || '', colorMap, isDarkTheme);
601
+ var color = (0, colors_1.getColorFromToken)(colors_1.DataVizPalette.success, isDarkTheme);
488
602
  sublabelColor = color;
489
603
  }
490
604
  else {
491
605
  sublabel = "\u25BC ".concat(Math.abs(diff));
492
- var color = (0, exports.getColor)(((_o = firstData.delta.decreasing) === null || _o === void 0 ? void 0 : _o.color) || '', colorMap, isDarkTheme);
606
+ var color = (0, colors_1.getColorFromToken)(colors_1.DataVizPalette.error, isDarkTheme);
493
607
  sublabelColor = color;
494
608
  }
495
609
  }
@@ -498,20 +612,20 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
498
612
  fill: sublabelColor,
499
613
  },
500
614
  };
501
- var chartTitle = getTitles(layout).chartTitle;
615
+ var chartTitle = getTitles(input.layout).chartTitle;
502
616
  return {
503
617
  segments: segments,
504
- chartValue: typeof firstData.value === 'number' ? firstData.value : 0,
618
+ chartValue: (_p = firstData.value) !== null && _p !== void 0 ? _p : 0,
505
619
  chartTitle: chartTitle,
506
620
  sublabel: sublabel,
507
621
  // range values can be null
508
- minValue: typeof ((_r = (_q = (_p = firstData.gauge) === null || _p === void 0 ? void 0 : _p.axis) === null || _q === void 0 ? void 0 : _q.range) === null || _r === void 0 ? void 0 : _r[0]) === 'number' ? (_u = (_t = (_s = firstData.gauge) === null || _s === void 0 ? void 0 : _s.axis) === null || _t === void 0 ? void 0 : _t.range) === null || _u === void 0 ? void 0 : _u[0] : undefined,
509
- maxValue: typeof ((_x = (_w = (_v = firstData.gauge) === null || _v === void 0 ? void 0 : _v.axis) === null || _w === void 0 ? void 0 : _w.range) === null || _x === void 0 ? void 0 : _x[1]) === 'number' ? (_0 = (_z = (_y = firstData.gauge) === null || _y === void 0 ? void 0 : _y.axis) === null || _z === void 0 ? void 0 : _z.range) === null || _0 === void 0 ? void 0 : _0[1] : undefined,
510
- chartValueFormat: function () { return firstData.value; },
511
- width: typeof (layout === null || layout === void 0 ? void 0 : layout.width) === 'number' ? layout === null || layout === void 0 ? void 0 : layout.width : 440,
512
- height: typeof (layout === null || layout === void 0 ? void 0 : layout.height) === 'number' ? layout === null || layout === void 0 ? void 0 : layout.height : 220,
622
+ minValue: typeof ((_s = (_r = (_q = firstData.gauge) === null || _q === void 0 ? void 0 : _q.axis) === null || _r === void 0 ? void 0 : _r.range) === null || _s === void 0 ? void 0 : _s[0]) === 'number' ? (_v = (_u = (_t = firstData.gauge) === null || _t === void 0 ? void 0 : _t.axis) === null || _u === void 0 ? void 0 : _u.range) === null || _v === void 0 ? void 0 : _v[0] : undefined,
623
+ maxValue: typeof ((_y = (_x = (_w = firstData.gauge) === null || _w === void 0 ? void 0 : _w.axis) === null || _x === void 0 ? void 0 : _x.range) === null || _y === void 0 ? void 0 : _y[1]) === 'number' ? (_1 = (_0 = (_z = firstData.gauge) === null || _z === void 0 ? void 0 : _z.axis) === null || _0 === void 0 ? void 0 : _0.range) === null || _1 === void 0 ? void 0 : _1[1] : undefined,
624
+ chartValueFormat: function () { var _a, _b; return (_b = (_a = firstData.value) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : ''; },
625
+ width: (_3 = (_2 = input.layout) === null || _2 === void 0 ? void 0 : _2.width) !== null && _3 !== void 0 ? _3 : 440,
626
+ height: (_5 = (_4 = input.layout) === null || _4 === void 0 ? void 0 : _4.height) !== null && _5 !== void 0 ? _5 : 220,
513
627
  styles: styles,
514
- variant: ((_2 = (_1 = firstData.gauge) === null || _1 === void 0 ? void 0 : _1.steps) === null || _2 === void 0 ? void 0 : _2.length) ? index_1.GaugeChartVariant.MultipleSegments : index_1.GaugeChartVariant.SingleSegment,
628
+ variant: ((_7 = (_6 = firstData.gauge) === null || _6 === void 0 ? void 0 : _6.steps) === null || _7 === void 0 ? void 0 : _7.length) ? index_1.GaugeChartVariant.MultipleSegments : index_1.GaugeChartVariant.SingleSegment,
515
629
  };
516
630
  };
517
631
  exports.transformPlotlyJsonToGaugeProps = transformPlotlyJsonToGaugeProps;