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