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