@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,47 +1,98 @@
|
|
|
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");
|
|
7
7
|
var d3_format_1 = require("d3-format");
|
|
8
8
|
var colors_1 = require("../../utilities/colors");
|
|
9
9
|
var index_1 = require("../GaugeChart/index");
|
|
10
|
-
var
|
|
10
|
+
var d3_time_format_1 = require("d3-time-format");
|
|
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
|
+
};
|
|
11
24
|
var isNumber = function (value) { return !isNaN(parseFloat(value)) && isFinite(value); };
|
|
12
|
-
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
|
+
};
|
|
13
53
|
exports.isDateArray = isDateArray;
|
|
14
|
-
var isNumberArray = function (
|
|
54
|
+
var isNumberArray = function (data) {
|
|
55
|
+
return isArrayOfType(data, isNumber);
|
|
56
|
+
};
|
|
15
57
|
exports.isNumberArray = isNumberArray;
|
|
16
|
-
var isMonthArray = function (
|
|
17
|
-
|
|
18
|
-
var presentYear_1 = new Date().getFullYear();
|
|
19
|
-
return array.every(function (possiblyMonthValue) {
|
|
20
|
-
return isDate("".concat(possiblyMonthValue, " 01, ").concat(presentYear_1));
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
return false;
|
|
58
|
+
var isMonthArray = function (data) {
|
|
59
|
+
return isArrayOfType(data, isMonth);
|
|
24
60
|
};
|
|
25
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
|
+
};
|
|
26
82
|
function getTitles(layout) {
|
|
27
|
-
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;
|
|
28
84
|
var titles = {
|
|
29
|
-
chartTitle: typeof layout.title === 'string' ? layout.title :
|
|
30
|
-
xAxisTitle: typeof ((
|
|
31
|
-
|
|
32
|
-
: 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'
|
|
33
|
-
? (_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
|
|
34
|
-
: '',
|
|
35
|
-
yAxisTitle: typeof ((_h = layout === null || layout === void 0 ? void 0 : layout.yaxis) === null || _h === void 0 ? void 0 : _h.title) === 'string'
|
|
36
|
-
? (_j = layout === null || layout === void 0 ? void 0 : layout.yaxis) === null || _j === void 0 ? void 0 : _j.title
|
|
37
|
-
: 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'
|
|
38
|
-
? (_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
|
|
39
|
-
: '',
|
|
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 : '',
|
|
40
88
|
};
|
|
41
89
|
return titles;
|
|
42
90
|
}
|
|
43
91
|
var updateXValues = function (xValues) {
|
|
44
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
|
+
}
|
|
45
96
|
var dates = xValues.map(function (possiblyMonthValue) {
|
|
46
97
|
var parsedDate = "".concat(possiblyMonthValue, " 01, ").concat(presentYear);
|
|
47
98
|
return isDate(parsedDate) ? new Date(parsedDate) : null;
|
|
@@ -73,21 +124,54 @@ var getColor = function (legendLabel, colorMap, isDarkTheme) {
|
|
|
73
124
|
return colorMap.current.get(legendLabel);
|
|
74
125
|
};
|
|
75
126
|
exports.getColor = getColor;
|
|
76
|
-
var
|
|
77
|
-
var _a
|
|
78
|
-
var
|
|
79
|
-
|
|
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];
|
|
80
164
|
var donutData = (_a = firstData.labels) === null || _a === void 0 ? void 0 : _a.map(function (label, index) {
|
|
81
165
|
var _a;
|
|
82
166
|
var color = (0, exports.getColor)(label, colorMap, isDarkTheme);
|
|
83
167
|
return {
|
|
84
168
|
legend: label,
|
|
85
|
-
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?
|
|
86
170
|
color: color,
|
|
87
171
|
};
|
|
88
172
|
});
|
|
89
|
-
var width =
|
|
90
|
-
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;
|
|
91
175
|
var hideLabels = firstData.textinfo
|
|
92
176
|
? !['value', 'percent', 'label+percent'].includes(firstData.textinfo)
|
|
93
177
|
: false;
|
|
@@ -98,57 +182,63 @@ var transformPlotlyJsonToDonutProps = function (jsonObj, colorMap, isDarkTheme)
|
|
|
98
182
|
: 0;
|
|
99
183
|
var styles = {
|
|
100
184
|
root: {
|
|
101
|
-
'[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 } : {})),
|
|
102
186
|
},
|
|
103
187
|
};
|
|
104
|
-
var chartTitle = getTitles(layout).chartTitle;
|
|
188
|
+
var chartTitle = getTitles(input.layout).chartTitle;
|
|
105
189
|
return {
|
|
106
190
|
data: {
|
|
107
191
|
chartTitle: chartTitle,
|
|
108
192
|
chartData: donutData,
|
|
109
193
|
},
|
|
110
|
-
hideLegend: (layout === null ||
|
|
194
|
+
hideLegend: ((_g = input.layout) === null || _g === void 0 ? void 0 : _g.showlegend) === false ? true : false,
|
|
111
195
|
width: width,
|
|
112
196
|
height: height,
|
|
113
197
|
innerRadius: innerRadius,
|
|
114
198
|
hideLabels: hideLabels,
|
|
115
|
-
showLabelsInPercent: firstData.textinfo ?
|
|
199
|
+
showLabelsInPercent: firstData.textinfo ? ['percent', 'label+percent'].includes(firstData.textinfo) : true,
|
|
116
200
|
styles: styles,
|
|
117
201
|
};
|
|
118
202
|
};
|
|
119
203
|
exports.transformPlotlyJsonToDonutProps = transformPlotlyJsonToDonutProps;
|
|
120
|
-
var transformPlotlyJsonToVSBCProps = function (
|
|
121
|
-
var data = jsonObj.data, layout = jsonObj.layout;
|
|
204
|
+
var transformPlotlyJsonToVSBCProps = function (input, colorMap, isDarkTheme, fallbackVSBC) {
|
|
122
205
|
var mapXToDataPoints = {};
|
|
123
206
|
var yMaxValue = 0;
|
|
124
|
-
|
|
207
|
+
var secondaryYAxisValues = {};
|
|
208
|
+
input.data.forEach(function (series, index1) {
|
|
125
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
|
+
}
|
|
126
214
|
(_a = series.x) === null || _a === void 0 ? void 0 : _a.forEach(function (x, index2) {
|
|
127
|
-
var _a, _b
|
|
215
|
+
var _a, _b;
|
|
128
216
|
if (!mapXToDataPoints[x]) {
|
|
129
217
|
mapXToDataPoints[x] = { xAxisPoint: x, chartData: [], lineData: [] };
|
|
130
218
|
}
|
|
131
|
-
var legend = series
|
|
132
|
-
|
|
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') {
|
|
133
222
|
var color = (0, exports.getColor)(legend, colorMap, isDarkTheme);
|
|
134
223
|
mapXToDataPoints[x].chartData.push({
|
|
135
224
|
legend: legend,
|
|
136
|
-
data:
|
|
225
|
+
data: yVal,
|
|
137
226
|
color: color,
|
|
138
227
|
});
|
|
139
228
|
}
|
|
140
|
-
else if (series.type === '
|
|
229
|
+
else if (series.type === 'scatter' || (0, exports.isLineData)(series) || !!fallbackVSBC) {
|
|
141
230
|
var color = (0, exports.getColor)(legend, colorMap, isDarkTheme);
|
|
142
231
|
mapXToDataPoints[x].lineData.push({
|
|
143
232
|
legend: legend,
|
|
144
|
-
y:
|
|
233
|
+
y: yVal,
|
|
145
234
|
color: color,
|
|
146
235
|
});
|
|
147
236
|
}
|
|
148
|
-
yMaxValue = Math.max(yMaxValue,
|
|
237
|
+
yMaxValue = Math.max(yMaxValue, yVal);
|
|
149
238
|
});
|
|
239
|
+
secondaryYAxisValues = getSecondaryYAxisValues(series, input.layout);
|
|
150
240
|
});
|
|
151
|
-
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;
|
|
152
242
|
return {
|
|
153
243
|
data: Object.values(mapXToDataPoints),
|
|
154
244
|
// width: layout?.width,
|
|
@@ -159,33 +249,40 @@ var transformPlotlyJsonToVSBCProps = function (jsonObj, colorMap, isDarkTheme) {
|
|
|
159
249
|
xAxisTitle: xAxisTitle,
|
|
160
250
|
yAxisTitle: yAxisTitle,
|
|
161
251
|
mode: 'plotly',
|
|
252
|
+
secondaryYAxistitle: secondaryYAxisValues.secondaryYAxistitle,
|
|
253
|
+
secondaryYScaleOptions: secondaryYAxisValues.secondaryYScaleOptions,
|
|
162
254
|
};
|
|
163
255
|
};
|
|
164
256
|
exports.transformPlotlyJsonToVSBCProps = transformPlotlyJsonToVSBCProps;
|
|
165
|
-
var transformPlotlyJsonToGVBCProps = function (
|
|
166
|
-
var data = jsonObj.data, layout = jsonObj.layout;
|
|
257
|
+
var transformPlotlyJsonToGVBCProps = function (input, colorMap, isDarkTheme) {
|
|
167
258
|
var mapXToDataPoints = {};
|
|
168
|
-
|
|
259
|
+
var secondaryYAxisValues = {};
|
|
260
|
+
input.data.forEach(function (series, index1) {
|
|
169
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
|
+
}
|
|
170
266
|
(_a = series.x) === null || _a === void 0 ? void 0 : _a.forEach(function (x, index2) {
|
|
171
|
-
var _a;
|
|
267
|
+
var _a, _b;
|
|
172
268
|
if (!mapXToDataPoints[x]) {
|
|
173
269
|
mapXToDataPoints[x] = { name: x.toString(), series: [] };
|
|
174
270
|
}
|
|
175
271
|
if (series.type === 'bar') {
|
|
176
|
-
var legend = series
|
|
272
|
+
var legend = getLegend(series, index1);
|
|
177
273
|
var color = (0, exports.getColor)(legend, colorMap, isDarkTheme);
|
|
178
274
|
mapXToDataPoints[x].series.push({
|
|
179
275
|
key: legend,
|
|
180
|
-
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,
|
|
181
277
|
xAxisCalloutData: x,
|
|
182
278
|
color: color,
|
|
183
279
|
legend: legend,
|
|
184
280
|
});
|
|
185
281
|
}
|
|
186
282
|
});
|
|
283
|
+
secondaryYAxisValues = getSecondaryYAxisValues(series, input.layout);
|
|
187
284
|
});
|
|
188
|
-
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;
|
|
189
286
|
return {
|
|
190
287
|
data: Object.values(mapXToDataPoints),
|
|
191
288
|
// width: layout?.width,
|
|
@@ -195,14 +292,16 @@ var transformPlotlyJsonToGVBCProps = function (jsonObj, colorMap, isDarkTheme) {
|
|
|
195
292
|
xAxisTitle: xAxisTitle,
|
|
196
293
|
yAxisTitle: yAxisTitle,
|
|
197
294
|
mode: 'plotly',
|
|
295
|
+
secondaryYAxistitle: secondaryYAxisValues.secondaryYAxistitle,
|
|
296
|
+
secondaryYScaleOptions: secondaryYAxisValues.secondaryYScaleOptions,
|
|
198
297
|
};
|
|
199
298
|
};
|
|
200
299
|
exports.transformPlotlyJsonToGVBCProps = transformPlotlyJsonToGVBCProps;
|
|
201
|
-
var transformPlotlyJsonToVBCProps = function (
|
|
202
|
-
var data = jsonObj.data, layout = jsonObj.layout;
|
|
300
|
+
var transformPlotlyJsonToVBCProps = function (input, colorMap, isDarkTheme) {
|
|
203
301
|
var vbcData = [];
|
|
204
|
-
data.forEach(function (series, index) {
|
|
302
|
+
input.data.forEach(function (series, index) {
|
|
205
303
|
var _a, _b, _c;
|
|
304
|
+
invalidate2Dseries(series, 'VBC');
|
|
206
305
|
if (!series.x) {
|
|
207
306
|
return;
|
|
208
307
|
}
|
|
@@ -230,7 +329,7 @@ var transformPlotlyJsonToVBCProps = function (jsonObj, colorMap, isDarkTheme) {
|
|
|
230
329
|
// If the start or end of xbins is specified, then the number of datapoints may become less than x.length
|
|
231
330
|
var totalDataPoints = (0, d3_array_1.merge)(buckets).length;
|
|
232
331
|
buckets.forEach(function (bucket) {
|
|
233
|
-
var legend = series
|
|
332
|
+
var legend = getLegend(series, index);
|
|
234
333
|
var color = (0, exports.getColor)(legend, colorMap, isDarkTheme);
|
|
235
334
|
var y = bucket.length;
|
|
236
335
|
if (series.histnorm === 'percent') {
|
|
@@ -266,12 +365,11 @@ var transformPlotlyJsonToVBCProps = function (jsonObj, colorMap, isDarkTheme) {
|
|
|
266
365
|
});
|
|
267
366
|
});
|
|
268
367
|
});
|
|
269
|
-
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;
|
|
270
369
|
return {
|
|
271
370
|
data: vbcData,
|
|
272
371
|
// width: layout?.width,
|
|
273
372
|
// height: layout?.height,
|
|
274
|
-
barWidth: 24,
|
|
275
373
|
supportNegativeData: true,
|
|
276
374
|
chartTitle: chartTitle,
|
|
277
375
|
xAxisTitle: xAxisTitle,
|
|
@@ -280,15 +378,19 @@ var transformPlotlyJsonToVBCProps = function (jsonObj, colorMap, isDarkTheme) {
|
|
|
280
378
|
};
|
|
281
379
|
};
|
|
282
380
|
exports.transformPlotlyJsonToVBCProps = transformPlotlyJsonToVBCProps;
|
|
283
|
-
var transformPlotlyJsonToScatterChartProps = function (
|
|
284
|
-
var
|
|
285
|
-
var
|
|
381
|
+
var transformPlotlyJsonToScatterChartProps = function (input, isAreaChart, colorMap, isDarkTheme) {
|
|
382
|
+
var secondaryYAxisValues = {};
|
|
383
|
+
var mode = 'tonexty';
|
|
384
|
+
var chartData = input.data.map(function (series, index) {
|
|
385
|
+
invalidate2Dseries(series, 'Scatter');
|
|
286
386
|
var xValues = series.x;
|
|
287
387
|
var isString = typeof xValues[0] === 'string';
|
|
288
388
|
var isXDate = (0, exports.isDateArray)(xValues);
|
|
289
389
|
var isXNumber = (0, exports.isNumberArray)(xValues);
|
|
290
|
-
var legend = series
|
|
390
|
+
var legend = getLegend(series, index);
|
|
291
391
|
var lineColor = (0, exports.getColor)(legend, colorMap, isDarkTheme);
|
|
392
|
+
secondaryYAxisValues = getSecondaryYAxisValues(series, input.layout);
|
|
393
|
+
mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
|
|
292
394
|
return {
|
|
293
395
|
legend: legend,
|
|
294
396
|
data: xValues.map(function (x, i) { return ({
|
|
@@ -298,7 +400,7 @@ var transformPlotlyJsonToScatterChartProps = function (jsonObj, isAreaChart, col
|
|
|
298
400
|
color: lineColor,
|
|
299
401
|
};
|
|
300
402
|
});
|
|
301
|
-
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;
|
|
302
404
|
var chartProps = {
|
|
303
405
|
chartTitle: chartTitle,
|
|
304
406
|
lineChartData: chartData,
|
|
@@ -309,6 +411,9 @@ var transformPlotlyJsonToScatterChartProps = function (jsonObj, isAreaChart, col
|
|
|
309
411
|
supportNegativeData: true,
|
|
310
412
|
xAxisTitle: xAxisTitle,
|
|
311
413
|
yAxisTitle: yAxisTitle,
|
|
414
|
+
secondaryYAxistitle: secondaryYAxisValues.secondaryYAxistitle,
|
|
415
|
+
secondaryYScaleOptions: secondaryYAxisValues.secondaryYScaleOptions,
|
|
416
|
+
mode: mode,
|
|
312
417
|
};
|
|
313
418
|
}
|
|
314
419
|
else {
|
|
@@ -317,15 +422,17 @@ var transformPlotlyJsonToScatterChartProps = function (jsonObj, isAreaChart, col
|
|
|
317
422
|
supportNegativeData: true,
|
|
318
423
|
xAxisTitle: xAxisTitle,
|
|
319
424
|
yAxisTitle: yAxisTitle,
|
|
425
|
+
secondaryYAxistitle: secondaryYAxisValues.secondaryYAxistitle,
|
|
426
|
+
secondaryYScaleOptions: secondaryYAxisValues.secondaryYScaleOptions,
|
|
320
427
|
};
|
|
321
428
|
}
|
|
322
429
|
};
|
|
323
430
|
exports.transformPlotlyJsonToScatterChartProps = transformPlotlyJsonToScatterChartProps;
|
|
324
|
-
var transformPlotlyJsonToHorizontalBarWithAxisProps = function (
|
|
325
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
326
|
-
var
|
|
327
|
-
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
|
|
328
434
|
.map(function (series, index) {
|
|
435
|
+
invalidate2Dseries(series, 'HBC');
|
|
329
436
|
return series.y.map(function (yValue, i) {
|
|
330
437
|
var color = (0, exports.getColor)(yValue, colorMap, isDarkTheme);
|
|
331
438
|
return {
|
|
@@ -336,48 +443,51 @@ var transformPlotlyJsonToHorizontalBarWithAxisProps = function (jsonObj, colorMa
|
|
|
336
443
|
};
|
|
337
444
|
});
|
|
338
445
|
})
|
|
339
|
-
.flat()
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
var
|
|
446
|
+
.flat()
|
|
447
|
+
//reversing the order to invert the Y bars order as required by plotly.
|
|
448
|
+
.reverse();
|
|
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;
|
|
343
452
|
var availableHeight = chartHeight - margin - padding;
|
|
344
|
-
var numberOfBars = data[0].y.length;
|
|
453
|
+
var numberOfBars = input.data[0].y.length;
|
|
345
454
|
var scalingFactor = 0.01;
|
|
346
455
|
var gapFactor = 1 / (1 + scalingFactor * numberOfBars);
|
|
347
456
|
var barHeight = availableHeight / (numberOfBars * (1 + gapFactor));
|
|
348
|
-
var
|
|
457
|
+
var _t = getTitles(input.layout), chartTitle = _t.chartTitle, xAxisTitle = _t.xAxisTitle, yAxisTitle = _t.yAxisTitle;
|
|
349
458
|
return {
|
|
350
459
|
data: chartData,
|
|
351
460
|
chartTitle: chartTitle,
|
|
352
461
|
xAxisTitle: xAxisTitle,
|
|
353
462
|
yAxisTitle: yAxisTitle,
|
|
354
|
-
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) || '',
|
|
355
466
|
barHeight: barHeight,
|
|
356
467
|
showYAxisLables: true,
|
|
357
468
|
styles: {
|
|
358
469
|
root: {
|
|
359
470
|
height: chartHeight,
|
|
360
|
-
width:
|
|
471
|
+
width: (_s = (_r = input.layout) === null || _r === void 0 ? void 0 : _r.width) !== null && _s !== void 0 ? _s : 600,
|
|
361
472
|
},
|
|
362
473
|
},
|
|
363
474
|
};
|
|
364
475
|
};
|
|
365
476
|
exports.transformPlotlyJsonToHorizontalBarWithAxisProps = transformPlotlyJsonToHorizontalBarWithAxisProps;
|
|
366
|
-
var transformPlotlyJsonToHeatmapProps = function (
|
|
477
|
+
var transformPlotlyJsonToHeatmapProps = function (input) {
|
|
367
478
|
var _a;
|
|
368
|
-
var
|
|
369
|
-
var firstData = data[0];
|
|
479
|
+
var firstData = input.data[0];
|
|
370
480
|
var heatmapDataPoints = [];
|
|
371
481
|
var zMin = Number.POSITIVE_INFINITY;
|
|
372
482
|
var zMax = Number.NEGATIVE_INFINITY;
|
|
373
483
|
(_a = firstData.x) === null || _a === void 0 ? void 0 : _a.forEach(function (xVal, xIdx) {
|
|
374
484
|
var _a;
|
|
375
485
|
(_a = firstData.y) === null || _a === void 0 ? void 0 : _a.forEach(function (yVal, yIdx) {
|
|
376
|
-
var _a, _b, _c, _d;
|
|
486
|
+
var _a, _b, _c, _d, _e, _f;
|
|
377
487
|
var zVal = (_b = (_a = firstData.z) === null || _a === void 0 ? void 0 : _a[yIdx]) === null || _b === void 0 ? void 0 : _b[xIdx];
|
|
378
488
|
heatmapDataPoints.push({
|
|
379
|
-
x: ((_c = layout
|
|
380
|
-
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,
|
|
381
491
|
value: zVal,
|
|
382
492
|
rectText: zVal,
|
|
383
493
|
});
|
|
@@ -386,16 +496,24 @@ var transformPlotlyJsonToHeatmapProps = function (jsonObj) {
|
|
|
386
496
|
});
|
|
387
497
|
});
|
|
388
498
|
var heatmapData = {
|
|
389
|
-
legend:
|
|
499
|
+
legend: firstData.name,
|
|
390
500
|
data: heatmapDataPoints,
|
|
391
501
|
value: 0,
|
|
392
502
|
};
|
|
393
|
-
//
|
|
394
|
-
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)
|
|
395
511
|
? firstData.colorscale.map(function (arr) { return arr[0] * (zMax - zMin) + zMin; })
|
|
396
|
-
:
|
|
397
|
-
var rangeValuesForColorScale =
|
|
398
|
-
|
|
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;
|
|
399
517
|
return {
|
|
400
518
|
data: [heatmapData],
|
|
401
519
|
domainValuesForColorScale: domainValuesForColorScale,
|
|
@@ -409,22 +527,20 @@ var transformPlotlyJsonToHeatmapProps = function (jsonObj) {
|
|
|
409
527
|
};
|
|
410
528
|
};
|
|
411
529
|
exports.transformPlotlyJsonToHeatmapProps = transformPlotlyJsonToHeatmapProps;
|
|
412
|
-
var transformPlotlyJsonToSankeyProps = function (
|
|
413
|
-
var _a, _b;
|
|
414
|
-
var
|
|
415
|
-
var
|
|
416
|
-
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 : [])
|
|
417
534
|
.map(function (val, index) { return ({
|
|
418
535
|
value: val,
|
|
419
|
-
source: link.source[index],
|
|
420
|
-
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],
|
|
421
538
|
}); })
|
|
422
539
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
423
|
-
//@ts-expect-error Dynamic link object. Ignore for now.
|
|
424
540
|
// Filter out negative nodes, unequal nodes and self-references (circular links)
|
|
425
541
|
.filter(function (x) { return x.source >= 0 && x.target >= 0 && x.source !== x.target; });
|
|
426
542
|
var sankeyChartData = {
|
|
427
|
-
nodes: node.label.map(function (label, index) {
|
|
543
|
+
nodes: (_b = node.label) === null || _b === void 0 ? void 0 : _b.map(function (label, index) {
|
|
428
544
|
var color = (0, exports.getColor)(label, colorMap, isDarkTheme);
|
|
429
545
|
return {
|
|
430
546
|
nodeId: index,
|
|
@@ -436,13 +552,13 @@ var transformPlotlyJsonToSankeyProps = function (jsonObj, colorMap, isDarkTheme)
|
|
|
436
552
|
return tslib_1.__assign({}, validLink);
|
|
437
553
|
}),
|
|
438
554
|
};
|
|
439
|
-
var width =
|
|
440
|
-
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;
|
|
441
557
|
var styles = {
|
|
442
|
-
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 } : {})),
|
|
443
559
|
};
|
|
444
560
|
var shouldResize = width + height;
|
|
445
|
-
var chartTitle = getTitles(layout).chartTitle;
|
|
561
|
+
var chartTitle = getTitles(input.layout).chartTitle;
|
|
446
562
|
return {
|
|
447
563
|
data: {
|
|
448
564
|
chartTitle: chartTitle,
|
|
@@ -456,10 +572,9 @@ var transformPlotlyJsonToSankeyProps = function (jsonObj, colorMap, isDarkTheme)
|
|
|
456
572
|
};
|
|
457
573
|
};
|
|
458
574
|
exports.transformPlotlyJsonToSankeyProps = transformPlotlyJsonToSankeyProps;
|
|
459
|
-
var transformPlotlyJsonToGaugeProps = function (
|
|
460
|
-
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;
|
|
461
|
-
var
|
|
462
|
-
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];
|
|
463
578
|
var segments = ((_b = (_a = firstData.gauge) === null || _a === void 0 ? void 0 : _a.steps) === null || _b === void 0 ? void 0 : _b.length)
|
|
464
579
|
? firstData.gauge.steps.map(function (step, index) {
|
|
465
580
|
var _a, _b;
|
|
@@ -474,27 +589,27 @@ var transformPlotlyJsonToGaugeProps = function (jsonObj, colorMap, isDarkTheme)
|
|
|
474
589
|
: [
|
|
475
590
|
{
|
|
476
591
|
legend: 'Current',
|
|
477
|
-
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),
|
|
478
593
|
color: (0, exports.getColor)('Current', colorMap, isDarkTheme),
|
|
479
594
|
},
|
|
480
595
|
{
|
|
481
596
|
legend: 'Target',
|
|
482
|
-
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),
|
|
483
598
|
color: colors_1.DataVizPalette.disabled,
|
|
484
599
|
},
|
|
485
600
|
];
|
|
486
601
|
var sublabel;
|
|
487
602
|
var sublabelColor;
|
|
488
|
-
if (
|
|
603
|
+
if ((_o = firstData.delta) === null || _o === void 0 ? void 0 : _o.reference) {
|
|
489
604
|
var diff = firstData.value - firstData.delta.reference;
|
|
490
605
|
if (diff >= 0) {
|
|
491
606
|
sublabel = "\u25B2 ".concat(diff);
|
|
492
|
-
var color = (0,
|
|
607
|
+
var color = (0, colors_1.getColorFromToken)(colors_1.DataVizPalette.success, isDarkTheme);
|
|
493
608
|
sublabelColor = color;
|
|
494
609
|
}
|
|
495
610
|
else {
|
|
496
611
|
sublabel = "\u25BC ".concat(Math.abs(diff));
|
|
497
|
-
var color = (0,
|
|
612
|
+
var color = (0, colors_1.getColorFromToken)(colors_1.DataVizPalette.error, isDarkTheme);
|
|
498
613
|
sublabelColor = color;
|
|
499
614
|
}
|
|
500
615
|
}
|
|
@@ -503,20 +618,20 @@ var transformPlotlyJsonToGaugeProps = function (jsonObj, colorMap, isDarkTheme)
|
|
|
503
618
|
fill: sublabelColor,
|
|
504
619
|
},
|
|
505
620
|
};
|
|
506
|
-
var chartTitle = getTitles(layout).chartTitle;
|
|
621
|
+
var chartTitle = getTitles(input.layout).chartTitle;
|
|
507
622
|
return {
|
|
508
623
|
segments: segments,
|
|
509
|
-
chartValue:
|
|
624
|
+
chartValue: (_p = firstData.value) !== null && _p !== void 0 ? _p : 0,
|
|
510
625
|
chartTitle: chartTitle,
|
|
511
626
|
sublabel: sublabel,
|
|
512
627
|
// range values can be null
|
|
513
|
-
minValue: typeof ((
|
|
514
|
-
maxValue: typeof ((
|
|
515
|
-
chartValueFormat: function () { return firstData.value; },
|
|
516
|
-
width:
|
|
517
|
-
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,
|
|
518
633
|
styles: styles,
|
|
519
|
-
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,
|
|
520
635
|
};
|
|
521
636
|
};
|
|
522
637
|
exports.transformPlotlyJsonToGaugeProps = transformPlotlyJsonToGaugeProps;
|