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