@fluentui/react-charting 5.23.88 → 5.23.89
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 +40 -1
- package/CHANGELOG.md +15 -2
- package/dist/react-charting.d.ts +72 -6
- package/dist/react-charting.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/etc/react-charting.api.md +37 -1
- package/lib/ChartTable.d.ts +1 -0
- package/lib/ChartTable.js +2 -0
- package/lib/ChartTable.js.map +1 -0
- package/lib/components/ChartTable/ChartTable.base.d.ts +10 -0
- package/lib/components/ChartTable/ChartTable.base.js +44 -0
- package/lib/components/ChartTable/ChartTable.base.js.map +1 -0
- package/lib/components/ChartTable/ChartTable.d.ts +7 -0
- package/lib/components/ChartTable/ChartTable.js +9 -0
- package/lib/components/ChartTable/ChartTable.js.map +1 -0
- package/lib/components/ChartTable/ChartTable.styles.d.ts +2 -0
- package/lib/components/ChartTable/ChartTable.styles.js +28 -0
- package/lib/components/ChartTable/ChartTable.styles.js.map +1 -0
- package/lib/components/ChartTable/ChartTable.types.d.ts +58 -0
- package/lib/components/ChartTable/ChartTable.types.js +2 -0
- package/lib/components/ChartTable/ChartTable.types.js.map +1 -0
- package/lib/components/ChartTable/index.d.ts +2 -0
- package/lib/components/ChartTable/index.js +3 -0
- package/lib/components/ChartTable/index.js.map +1 -0
- package/lib/components/DeclarativeChart/DeclarativeChart.d.ts +7 -6
- package/lib/components/DeclarativeChart/DeclarativeChart.js +15 -12
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.d.ts +7 -0
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +103 -0
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +13 -13
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +141 -120
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/utilities/image-export-utils.js +25 -3
- package/lib/utilities/image-export-utils.js.map +1 -1
- package/lib-amd/ChartTable.d.ts +1 -0
- package/lib-amd/ChartTable.js +6 -0
- package/lib-amd/ChartTable.js.map +1 -0
- package/lib-amd/components/ChartTable/ChartTable.base.d.ts +10 -0
- package/lib-amd/components/ChartTable/ChartTable.base.js +45 -0
- package/lib-amd/components/ChartTable/ChartTable.base.js.map +1 -0
- package/lib-amd/components/ChartTable/ChartTable.d.ts +7 -0
- package/lib-amd/components/ChartTable/ChartTable.js +11 -0
- package/lib-amd/components/ChartTable/ChartTable.js.map +1 -0
- package/lib-amd/components/ChartTable/ChartTable.styles.d.ts +2 -0
- package/lib-amd/components/ChartTable/ChartTable.styles.js +32 -0
- package/lib-amd/components/ChartTable/ChartTable.styles.js.map +1 -0
- package/lib-amd/components/ChartTable/ChartTable.types.d.ts +58 -0
- package/lib-amd/components/ChartTable/ChartTable.types.js +5 -0
- package/lib-amd/components/ChartTable/ChartTable.types.js.map +1 -0
- package/lib-amd/components/ChartTable/index.d.ts +2 -0
- package/lib-amd/components/ChartTable/index.js +7 -0
- package/lib-amd/components/ChartTable/index.js.map +1 -0
- package/lib-amd/components/DeclarativeChart/DeclarativeChart.d.ts +7 -6
- package/lib-amd/components/DeclarativeChart/DeclarativeChart.js +14 -12
- package/lib-amd/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/PlotlyColorAdapter.d.ts +7 -0
- package/lib-amd/components/DeclarativeChart/PlotlyColorAdapter.js +108 -0
- package/lib-amd/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +13 -13
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +143 -124
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-amd/index.d.ts +2 -0
- package/lib-amd/index.js +3 -2
- package/lib-amd/index.js.map +1 -1
- package/lib-amd/utilities/image-export-utils.js +25 -3
- package/lib-amd/utilities/image-export-utils.js.map +1 -1
- package/lib-commonjs/ChartTable.d.ts +1 -0
- package/lib-commonjs/ChartTable.js +5 -0
- package/lib-commonjs/ChartTable.js.map +1 -0
- package/lib-commonjs/components/ChartTable/ChartTable.base.d.ts +10 -0
- package/lib-commonjs/components/ChartTable/ChartTable.base.js +47 -0
- package/lib-commonjs/components/ChartTable/ChartTable.base.js.map +1 -0
- package/lib-commonjs/components/ChartTable/ChartTable.d.ts +7 -0
- package/lib-commonjs/components/ChartTable/ChartTable.js +12 -0
- package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -0
- package/lib-commonjs/components/ChartTable/ChartTable.styles.d.ts +2 -0
- package/lib-commonjs/components/ChartTable/ChartTable.styles.js +32 -0
- package/lib-commonjs/components/ChartTable/ChartTable.styles.js.map +1 -0
- package/lib-commonjs/components/ChartTable/ChartTable.types.d.ts +58 -0
- package/lib-commonjs/components/ChartTable/ChartTable.types.js +3 -0
- package/lib-commonjs/components/ChartTable/ChartTable.types.js.map +1 -0
- package/lib-commonjs/components/ChartTable/index.d.ts +2 -0
- package/lib-commonjs/components/ChartTable/index.js +6 -0
- package/lib-commonjs/components/ChartTable/index.js.map +1 -0
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.d.ts +7 -6
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +14 -11
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.d.ts +7 -0
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +110 -0
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +13 -13
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +143 -124
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/index.d.ts +2 -0
- package/lib-commonjs/index.js +3 -1
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/utilities/image-export-utils.js +25 -3
- package/lib-commonjs/utilities/image-export-utils.js.map +1 -1
- package/package.json +2 -2
- package/src/components/ChartTable/ChartTable.types.ts +68 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findArrayAttributes = exports.projectPolarToCartesian = exports.transformPlotlyJsonToGaugeProps = exports.transformPlotlyJsonToSankeyProps = exports.transformPlotlyJsonToHeatmapProps = exports.transformPlotlyJsonToHorizontalBarWithAxisProps = exports.transformPlotlyJsonToScatterChartProps = exports.transformPlotlyJsonToVBCProps = exports.transformPlotlyJsonToGVBCProps = exports.transformPlotlyJsonToVSBCProps = exports.transformPlotlyJsonToDonutProps = exports.
|
|
3
|
+
exports.findArrayAttributes = exports.projectPolarToCartesian = exports.transformPlotlyJsonToChartTableProps = exports.transformPlotlyJsonToGaugeProps = exports.transformPlotlyJsonToSankeyProps = exports.transformPlotlyJsonToHeatmapProps = exports.transformPlotlyJsonToHorizontalBarWithAxisProps = exports.transformPlotlyJsonToScatterChartProps = exports.transformPlotlyJsonToVBCProps = exports.transformPlotlyJsonToGVBCProps = exports.transformPlotlyJsonToVSBCProps = exports.transformPlotlyJsonToDonutProps = exports._getGaugeAxisColor = exports.correctYearMonth = exports.isMonthArray = 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");
|
|
@@ -10,7 +10,7 @@ var utilities_1 = require("../../utilities/utilities");
|
|
|
10
10
|
var chart_utilities_1 = require("@fluentui/chart-utilities");
|
|
11
11
|
var d3_time_format_1 = require("d3-time-format");
|
|
12
12
|
var d3_shape_1 = require("d3-shape");
|
|
13
|
-
var
|
|
13
|
+
var PlotlyColorAdapter_1 = require("./PlotlyColorAdapter");
|
|
14
14
|
var dashOptions = {
|
|
15
15
|
dot: {
|
|
16
16
|
strokeDasharray: '1, 5',
|
|
@@ -49,6 +49,7 @@ var dashOptions = {
|
|
|
49
49
|
lineBorderWidth: '4',
|
|
50
50
|
},
|
|
51
51
|
};
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
53
|
var isMonth = function (possiblyMonthValue) {
|
|
53
54
|
var parseFullMonth = (0, d3_time_format_1.timeParse)('%B');
|
|
54
55
|
var parseShortMonth = (0, d3_time_format_1.timeParse)('%b');
|
|
@@ -67,6 +68,7 @@ function getTitles(layout) {
|
|
|
67
68
|
};
|
|
68
69
|
return titles;
|
|
69
70
|
}
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
70
72
|
var correctYearMonth = function (xValues) {
|
|
71
73
|
var presentYear = new Date().getFullYear();
|
|
72
74
|
if (xValues.length > 0 && Array.isArray(xValues[0])) {
|
|
@@ -94,15 +96,6 @@ var correctYearMonth = function (xValues) {
|
|
|
94
96
|
return xValues;
|
|
95
97
|
};
|
|
96
98
|
exports.correctYearMonth = correctYearMonth;
|
|
97
|
-
var getColor = function (legendLabel, colorMap, isDarkTheme) {
|
|
98
|
-
if (!colorMap.current.has(legendLabel)) {
|
|
99
|
-
var nextColor = (0, colors_1.getNextColor)(colorMap.current.size + 1, 0, isDarkTheme);
|
|
100
|
-
colorMap.current.set(legendLabel, nextColor);
|
|
101
|
-
return nextColor;
|
|
102
|
-
}
|
|
103
|
-
return colorMap.current.get(legendLabel);
|
|
104
|
-
};
|
|
105
|
-
exports.getColor = getColor;
|
|
106
99
|
var usesSecondaryYScale = function (series) {
|
|
107
100
|
return series.yaxis === 'y2';
|
|
108
101
|
};
|
|
@@ -146,59 +139,21 @@ var getSecondaryYAxisValues = function (data, layout, maxAllowedMinY, minAllowed
|
|
|
146
139
|
},
|
|
147
140
|
};
|
|
148
141
|
};
|
|
149
|
-
var
|
|
150
|
-
var
|
|
151
|
-
|
|
152
|
-
return undefined;
|
|
153
|
-
}
|
|
154
|
-
if ((0, chart_utilities_1.isArrayOrTypedArray)(colors)) {
|
|
155
|
-
colors.forEach(function (element, index) {
|
|
156
|
-
var colorString = element === null || element === void 0 ? void 0 : element.toString().trim();
|
|
157
|
-
var nextFluentColor = (0, exports.getColor)("Label_".concat(index), colorMap, isDarkTheme);
|
|
158
|
-
if (colorString) {
|
|
159
|
-
var parsedColor = (0, d3_color_1.color)(colorString);
|
|
160
|
-
hexColors.push(parsedColor ? parsedColor.formatHex() : nextFluentColor);
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
hexColors.push(nextFluentColor);
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
else if (typeof colors === 'string') {
|
|
168
|
-
var parsedColor = (0, d3_color_1.color)(colors);
|
|
169
|
-
return parsedColor ? parsedColor.formatHex() : (0, exports.getColor)('Label_0', colorMap, isDarkTheme);
|
|
170
|
-
}
|
|
171
|
-
return hexColors;
|
|
172
|
-
};
|
|
173
|
-
exports.getSchemaColors = getSchemaColors;
|
|
174
|
-
var _extractColor = function (useFluentVizColorPalette, colors, colorMap, isDarkTheme) {
|
|
175
|
-
return !useFluentVizColorPalette && colors ? (0, exports.getSchemaColors)(colors, colorMap, isDarkTheme) : undefined;
|
|
176
|
-
};
|
|
177
|
-
exports._extractColor = _extractColor;
|
|
178
|
-
var _resolveColor = function (extractedColors, index, legend, colorMap, isDarkTheme) {
|
|
179
|
-
var color = '';
|
|
180
|
-
if (extractedColors && (0, chart_utilities_1.isArrayOrTypedArray)(extractedColors) && extractedColors[index]) {
|
|
181
|
-
color = extractedColors[index % extractedColors.length];
|
|
182
|
-
}
|
|
183
|
-
else if (typeof extractedColors === 'string') {
|
|
184
|
-
color = extractedColors;
|
|
185
|
-
}
|
|
186
|
-
else {
|
|
187
|
-
color = (0, exports.getColor)(legend, colorMap, isDarkTheme);
|
|
188
|
-
}
|
|
189
|
-
return color;
|
|
142
|
+
var _getGaugeAxisColor = function (colorway, colorwayType, color, colorMap, isDarkTheme) {
|
|
143
|
+
var extractedColors = (0, PlotlyColorAdapter_1.extractColor)(colorway, colorwayType, color, colorMap, isDarkTheme);
|
|
144
|
+
return (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, 0, '', colorMap, isDarkTheme);
|
|
190
145
|
};
|
|
191
|
-
exports.
|
|
192
|
-
var transformPlotlyJsonToDonutProps = function (input, colorMap,
|
|
193
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
146
|
+
exports._getGaugeAxisColor = _getGaugeAxisColor;
|
|
147
|
+
var transformPlotlyJsonToDonutProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
148
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
194
149
|
var firstData = input.data[0];
|
|
195
150
|
// extract colors for each series only once
|
|
196
|
-
var colors = (0,
|
|
151
|
+
var colors = (0, PlotlyColorAdapter_1.extractColor)((_c = (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.template) === null || _b === void 0 ? void 0 : _b.layout) === null || _c === void 0 ? void 0 : _c.colorway, colorwayType, (_d = firstData === null || firstData === void 0 ? void 0 : firstData.marker) === null || _d === void 0 ? void 0 : _d.colors, colorMap, isDarkTheme);
|
|
197
152
|
var mapLegendToDataPoint = {};
|
|
198
|
-
(
|
|
153
|
+
(_e = firstData.labels) === null || _e === void 0 ? void 0 : _e.forEach(function (label, index) {
|
|
199
154
|
var _a;
|
|
200
155
|
// resolve color for each legend from the extracted colors
|
|
201
|
-
var color = (0,
|
|
156
|
+
var color = (0, PlotlyColorAdapter_1.resolveColor)(colors, index, label, colorMap, isDarkTheme);
|
|
202
157
|
//ToDo how to handle string data?
|
|
203
158
|
var value = typeof ((_a = firstData.values) === null || _a === void 0 ? void 0 : _a[index]) === 'number' ? firstData.values[index] : 1;
|
|
204
159
|
if (!mapLegendToDataPoint[label]) {
|
|
@@ -212,8 +167,8 @@ var transformPlotlyJsonToDonutProps = function (input, colorMap, useFluentVizCol
|
|
|
212
167
|
mapLegendToDataPoint[label].data += value;
|
|
213
168
|
}
|
|
214
169
|
});
|
|
215
|
-
var width = (
|
|
216
|
-
var height = (
|
|
170
|
+
var width = (_g = (_f = input.layout) === null || _f === void 0 ? void 0 : _f.width) !== null && _g !== void 0 ? _g : 440;
|
|
171
|
+
var height = (_j = (_h = input.layout) === null || _h === void 0 ? void 0 : _h.height) !== null && _j !== void 0 ? _j : 220;
|
|
217
172
|
var hideLabels = firstData.textinfo
|
|
218
173
|
? !['value', 'percent', 'label+percent'].includes(firstData.textinfo)
|
|
219
174
|
: false;
|
|
@@ -228,36 +183,37 @@ var transformPlotlyJsonToDonutProps = function (input, colorMap, useFluentVizCol
|
|
|
228
183
|
chartTitle: chartTitle,
|
|
229
184
|
chartData: Object.values(mapLegendToDataPoint),
|
|
230
185
|
},
|
|
231
|
-
hideLegend: ((
|
|
232
|
-
width: (
|
|
186
|
+
hideLegend: ((_k = input.layout) === null || _k === void 0 ? void 0 : _k.showlegend) === false ? true : false,
|
|
187
|
+
width: (_l = input.layout) === null || _l === void 0 ? void 0 : _l.width,
|
|
233
188
|
height: height,
|
|
234
189
|
innerRadius: innerRadius,
|
|
235
190
|
hideLabels: hideLabels,
|
|
236
191
|
showLabelsInPercent: firstData.textinfo ? ['percent', 'label+percent'].includes(firstData.textinfo) : true,
|
|
192
|
+
roundCorners: true,
|
|
237
193
|
};
|
|
238
194
|
};
|
|
239
195
|
exports.transformPlotlyJsonToDonutProps = transformPlotlyJsonToDonutProps;
|
|
240
|
-
var transformPlotlyJsonToVSBCProps = function (input, colorMap,
|
|
196
|
+
var transformPlotlyJsonToVSBCProps = function (input, colorMap, colorwayType, isDarkTheme, fallbackVSBC) {
|
|
241
197
|
var _a, _b, _c;
|
|
242
198
|
var mapXToDataPoints = {};
|
|
243
199
|
var yMaxValue = 0;
|
|
244
200
|
var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
|
|
245
201
|
var _d = getLegendProps(input.data, input.layout), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
246
202
|
input.data.forEach(function (series, index1) {
|
|
247
|
-
var _a, _b, _c;
|
|
203
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
248
204
|
var isXYearCategory = (0, chart_utilities_1.isYearArray)(series.x); // Consider year as categorical not numeric continuous axis
|
|
249
205
|
// extract bar colors for each series only once
|
|
250
|
-
var extractedBarColors = (0,
|
|
206
|
+
var extractedBarColors = (0, PlotlyColorAdapter_1.extractColor)((_c = (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.template) === null || _b === void 0 ? void 0 : _b.layout) === null || _c === void 0 ? void 0 : _c.colorway, colorwayType, (_d = series.marker) === null || _d === void 0 ? void 0 : _d.color, colorMap, isDarkTheme);
|
|
251
207
|
// extract line colors for each series only once
|
|
252
|
-
var extractedLineColors = (0,
|
|
253
|
-
(
|
|
208
|
+
var extractedLineColors = (0, PlotlyColorAdapter_1.extractColor)((_g = (_f = (_e = input.layout) === null || _e === void 0 ? void 0 : _e.template) === null || _f === void 0 ? void 0 : _f.layout) === null || _g === void 0 ? void 0 : _g.colorway, colorwayType, (_h = series.line) === null || _h === void 0 ? void 0 : _h.color, colorMap, isDarkTheme);
|
|
209
|
+
(_j = series.x) === null || _j === void 0 ? void 0 : _j.forEach(function (x, index2) {
|
|
254
210
|
var _a, _b, _c;
|
|
255
211
|
if (!mapXToDataPoints[x]) {
|
|
256
212
|
mapXToDataPoints[x] = { xAxisPoint: isXYearCategory ? x.toString() : x, chartData: [], lineData: [] };
|
|
257
213
|
}
|
|
258
214
|
var legend = legends[index1];
|
|
259
215
|
// resolve color for each legend's bars from the extracted colors
|
|
260
|
-
var color = (0,
|
|
216
|
+
var color = (0, PlotlyColorAdapter_1.resolveColor)(extractedBarColors, index1, legend, colorMap, isDarkTheme);
|
|
261
217
|
var yVal = (_b = (_a = series.y) === null || _a === void 0 ? void 0 : _a[index2]) !== null && _b !== void 0 ? _b : 0;
|
|
262
218
|
if (series.type === 'bar') {
|
|
263
219
|
mapXToDataPoints[x].chartData.push({
|
|
@@ -268,7 +224,7 @@ var transformPlotlyJsonToVSBCProps = function (input, colorMap, useFluentVizColo
|
|
|
268
224
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
269
225
|
}
|
|
270
226
|
else if (series.type === 'scatter' || !!fallbackVSBC) {
|
|
271
|
-
var lineColor = (0,
|
|
227
|
+
var lineColor = (0, PlotlyColorAdapter_1.resolveColor)(extractedLineColors, index1, legend, colorMap, isDarkTheme);
|
|
272
228
|
var lineOptions = getLineOptions(series.line);
|
|
273
229
|
var dashType = ((_c = series.line) === null || _c === void 0 ? void 0 : _c.dash) || 'solid';
|
|
274
230
|
var legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot' ? 'dottedLine' : 'default';
|
|
@@ -280,19 +236,19 @@ var transformPlotlyJsonToVSBCProps = function (input, colorMap, useFluentVizColo
|
|
|
280
236
|
});
|
|
281
237
|
});
|
|
282
238
|
var _e = getTitles(input.layout), chartTitle = _e.chartTitle, xAxisTitle = _e.xAxisTitle, yAxisTitle = _e.yAxisTitle;
|
|
283
|
-
return tslib_1.__assign(tslib_1.__assign({ data: Object.values(mapXToDataPoints), width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, barWidth: 'auto', yMaxValue: yMaxValue, chartTitle: chartTitle, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle, mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend });
|
|
239
|
+
return tslib_1.__assign(tslib_1.__assign({ data: Object.values(mapXToDataPoints), width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, barWidth: 'auto', yMaxValue: yMaxValue, chartTitle: chartTitle, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle, mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true });
|
|
284
240
|
};
|
|
285
241
|
exports.transformPlotlyJsonToVSBCProps = transformPlotlyJsonToVSBCProps;
|
|
286
|
-
var transformPlotlyJsonToGVBCProps = function (input, colorMap,
|
|
242
|
+
var transformPlotlyJsonToGVBCProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
287
243
|
var _a, _b, _c;
|
|
288
244
|
var mapXToDataPoints = {};
|
|
289
245
|
var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, 0, 0);
|
|
290
246
|
var _d = getLegendProps(input.data, input.layout), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
291
247
|
input.data.forEach(function (series, index1) {
|
|
292
|
-
var _a, _b;
|
|
248
|
+
var _a, _b, _c, _d, _e;
|
|
293
249
|
// extract colors for each series only once
|
|
294
|
-
var extractedColors = (0,
|
|
295
|
-
(
|
|
250
|
+
var extractedColors = (0, PlotlyColorAdapter_1.extractColor)((_c = (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.template) === null || _b === void 0 ? void 0 : _b.layout) === null || _c === void 0 ? void 0 : _c.colorway, colorwayType, (_d = series.marker) === null || _d === void 0 ? void 0 : _d.color, colorMap, isDarkTheme);
|
|
251
|
+
(_e = series.x) === null || _e === void 0 ? void 0 : _e.forEach(function (x, xIndex) {
|
|
296
252
|
var _a, _b;
|
|
297
253
|
if (!mapXToDataPoints[x]) {
|
|
298
254
|
mapXToDataPoints[x] = { name: x.toString(), series: [] };
|
|
@@ -300,7 +256,7 @@ var transformPlotlyJsonToGVBCProps = function (input, colorMap, useFluentVizColo
|
|
|
300
256
|
if (series.type === 'bar') {
|
|
301
257
|
var legend = legends[index1];
|
|
302
258
|
// resolve color for each legend's bars from the extracted colors
|
|
303
|
-
var color = (0,
|
|
259
|
+
var color = (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, index1, legend, colorMap, isDarkTheme);
|
|
304
260
|
mapXToDataPoints[x].series.push({
|
|
305
261
|
key: legend,
|
|
306
262
|
data: (_b = (_a = series.y) === null || _a === void 0 ? void 0 : _a[xIndex]) !== null && _b !== void 0 ? _b : 0,
|
|
@@ -313,24 +269,24 @@ var transformPlotlyJsonToGVBCProps = function (input, colorMap, useFluentVizColo
|
|
|
313
269
|
});
|
|
314
270
|
});
|
|
315
271
|
var _e = getTitles(input.layout), chartTitle = _e.chartTitle, xAxisTitle = _e.xAxisTitle, yAxisTitle = _e.yAxisTitle;
|
|
316
|
-
return tslib_1.__assign(tslib_1.__assign({ data: Object.values(mapXToDataPoints), width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, barwidth: 'auto', chartTitle: chartTitle, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle, mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend });
|
|
272
|
+
return tslib_1.__assign(tslib_1.__assign({ data: Object.values(mapXToDataPoints), width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, barwidth: 'auto', chartTitle: chartTitle, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle, mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true });
|
|
317
273
|
};
|
|
318
274
|
exports.transformPlotlyJsonToGVBCProps = transformPlotlyJsonToGVBCProps;
|
|
319
|
-
var transformPlotlyJsonToVBCProps = function (input, colorMap,
|
|
275
|
+
var transformPlotlyJsonToVBCProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
320
276
|
var _a, _b, _c;
|
|
321
277
|
var vbcData = [];
|
|
322
278
|
var _d = getLegendProps(input.data, input.layout), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
323
279
|
input.data.forEach(function (series, seriesIdx) {
|
|
324
|
-
var _a, _b, _c, _d;
|
|
280
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
325
281
|
if (!series.x) {
|
|
326
282
|
return;
|
|
327
283
|
}
|
|
328
284
|
// extract colors for each series only once
|
|
329
|
-
var extractedColors = (0,
|
|
285
|
+
var extractedColors = (0, PlotlyColorAdapter_1.extractColor)((_c = (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.template) === null || _b === void 0 ? void 0 : _b.layout) === null || _c === void 0 ? void 0 : _c.colorway, colorwayType, (_d = series.marker) === null || _d === void 0 ? void 0 : _d.color, colorMap, isDarkTheme);
|
|
330
286
|
var isXString = isStringArray(series.x);
|
|
331
287
|
// TODO: In case of a single bin, add an empty bin of the same size to prevent the
|
|
332
288
|
// default bar width from being used and ensure the bar spans the full intended range.
|
|
333
|
-
var xBins = createBins(series.x, (
|
|
289
|
+
var xBins = createBins(series.x, (_e = series.xbins) === null || _e === void 0 ? void 0 : _e.start, (_f = series.xbins) === null || _f === void 0 ? void 0 : _f.end, (_g = series.xbins) === null || _g === void 0 ? void 0 : _g.size);
|
|
334
290
|
var yBins = xBins.map(function () { return []; });
|
|
335
291
|
var total = 0;
|
|
336
292
|
series.x.forEach(function (xVal, index) {
|
|
@@ -348,7 +304,7 @@ var transformPlotlyJsonToVBCProps = function (input, colorMap, useFluentVizColor
|
|
|
348
304
|
xBins.forEach(function (bin, index) {
|
|
349
305
|
var legend = legends[seriesIdx];
|
|
350
306
|
// resolve color for each legend's bars from the extracted colors
|
|
351
|
-
var color = (0,
|
|
307
|
+
var color = (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, seriesIdx, legend, colorMap, isDarkTheme);
|
|
352
308
|
var yVal = calculateHistNorm(series.histnorm, y[index], total, isXString ? bin.length : getBinSize(bin));
|
|
353
309
|
vbcData.push(tslib_1.__assign({ x: isXString ? bin.join(', ') : getBinCenter(bin), y: yVal, legend: legend, color: color }, (isXString
|
|
354
310
|
? {}
|
|
@@ -368,28 +324,29 @@ var transformPlotlyJsonToVBCProps = function (input, colorMap, useFluentVizColor
|
|
|
368
324
|
hideTickOverlap: true,
|
|
369
325
|
maxBarWidth: 50,
|
|
370
326
|
hideLegend: hideLegend,
|
|
327
|
+
roundCorners: true,
|
|
371
328
|
};
|
|
372
329
|
};
|
|
373
330
|
exports.transformPlotlyJsonToVBCProps = transformPlotlyJsonToVBCProps;
|
|
374
|
-
var transformPlotlyJsonToScatterChartProps = function (input, isAreaChart, colorMap,
|
|
331
|
+
var transformPlotlyJsonToScatterChartProps = function (input, isAreaChart, isScatterMarkers, colorMap, colorwayType, isDarkTheme) {
|
|
375
332
|
var _a, _b, _c, _d, _e, _f;
|
|
376
333
|
var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
|
|
377
334
|
var mode = 'tonexty';
|
|
378
335
|
var _g = getLegendProps(input.data, input.layout), legends = _g.legends, hideLegend = _g.hideLegend;
|
|
379
336
|
var chartData = input.data.map(function (series, index) {
|
|
380
|
-
var _a, _b;
|
|
337
|
+
var _a, _b, _c, _d, _e, _f;
|
|
381
338
|
// extract colors for each series only once
|
|
382
|
-
var extractedColors = (0,
|
|
339
|
+
var extractedColors = (0, PlotlyColorAdapter_1.extractColor)((_c = (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.template) === null || _b === void 0 ? void 0 : _b.layout) === null || _c === void 0 ? void 0 : _c.colorway, colorwayType, isScatterMarkers ? (_d = series.marker) === null || _d === void 0 ? void 0 : _d.color : (_e = series.line) === null || _e === void 0 ? void 0 : _e.color, colorMap, isDarkTheme);
|
|
383
340
|
var xValues = series.x;
|
|
384
341
|
var isString = typeof xValues[0] === 'string';
|
|
385
342
|
var isXDate = (0, chart_utilities_1.isDateArray)(xValues);
|
|
386
343
|
var isXNumber = (0, chart_utilities_1.isNumberArray)(xValues);
|
|
387
344
|
var legend = legends[index];
|
|
388
345
|
// resolve color for each legend's lines from the extracted colors
|
|
389
|
-
var
|
|
346
|
+
var seriesColor = (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
390
347
|
mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
|
|
391
348
|
var lineOptions = getLineOptions(series.line);
|
|
392
|
-
var dashType = ((
|
|
349
|
+
var dashType = ((_f = series.line) === null || _f === void 0 ? void 0 : _f.dash) || 'solid';
|
|
393
350
|
var legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot' ? 'dottedLine' : 'default';
|
|
394
351
|
return tslib_1.__assign(tslib_1.__assign({ legend: legend, legendShape: legendShape, data: xValues.map(function (x, i) {
|
|
395
352
|
var _a, _b;
|
|
@@ -398,7 +355,7 @@ var transformPlotlyJsonToScatterChartProps = function (input, isAreaChart, color
|
|
|
398
355
|
: typeof ((_b = series.marker) === null || _b === void 0 ? void 0 : _b.size) === 'number'
|
|
399
356
|
? { markerSize: series.marker.size }
|
|
400
357
|
: {})));
|
|
401
|
-
}), color:
|
|
358
|
+
}), color: seriesColor }, (lineOptions ? { lineOptions: lineOptions } : {})), { useSecondaryYScale: usesSecondaryYScale(series) });
|
|
402
359
|
});
|
|
403
360
|
var yMinMaxValues = (0, utilities_1.findNumericMinMaxOfY)(chartData);
|
|
404
361
|
var _h = getTitles(input.layout), chartTitle = _h.chartTitle, xAxisTitle = _h.xAxisTitle, yAxisTitle = _h.yAxisTitle;
|
|
@@ -414,17 +371,17 @@ var transformPlotlyJsonToScatterChartProps = function (input, isAreaChart, color
|
|
|
414
371
|
}
|
|
415
372
|
};
|
|
416
373
|
exports.transformPlotlyJsonToScatterChartProps = transformPlotlyJsonToScatterChartProps;
|
|
417
|
-
var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, colorMap,
|
|
374
|
+
var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
418
375
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
419
376
|
var _s = getLegendProps(input.data, input.layout), legends = _s.legends, hideLegend = _s.hideLegend;
|
|
420
377
|
var chartData = input.data
|
|
421
378
|
.map(function (series, index) {
|
|
422
|
-
var _a;
|
|
379
|
+
var _a, _b, _c, _d;
|
|
423
380
|
// extract colors for each series only once
|
|
424
|
-
var extractedColors = (0,
|
|
381
|
+
var extractedColors = (0, PlotlyColorAdapter_1.extractColor)((_c = (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.template) === null || _b === void 0 ? void 0 : _b.layout) === null || _c === void 0 ? void 0 : _c.colorway, colorwayType, (_d = series.marker) === null || _d === void 0 ? void 0 : _d.color, colorMap, isDarkTheme);
|
|
425
382
|
var legend = legends[index];
|
|
426
383
|
// resolve color for each legend's bars from the extracted colors
|
|
427
|
-
var color = (0,
|
|
384
|
+
var color = (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
428
385
|
return series.y.map(function (yValue, i) {
|
|
429
386
|
return {
|
|
430
387
|
x: series.x[i],
|
|
@@ -466,6 +423,7 @@ var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, colorMap,
|
|
|
466
423
|
hideLegend: hideLegend,
|
|
467
424
|
noOfCharsToTruncate: 20,
|
|
468
425
|
showYAxisLablesTooltip: true,
|
|
426
|
+
roundCorners: true,
|
|
469
427
|
};
|
|
470
428
|
};
|
|
471
429
|
exports.transformPlotlyJsonToHorizontalBarWithAxisProps = transformPlotlyJsonToHorizontalBarWithAxisProps;
|
|
@@ -516,6 +474,7 @@ var transformPlotlyJsonToHeatmapProps = function (input) {
|
|
|
516
474
|
else {
|
|
517
475
|
(_h = firstData.x) === null || _h === void 0 ? void 0 : _h.forEach(function (xVal, xIdx) {
|
|
518
476
|
var _a;
|
|
477
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
519
478
|
(_a = firstData.y) === null || _a === void 0 ? void 0 : _a.forEach(function (yVal, yIdx) {
|
|
520
479
|
var _a, _b, _c, _d, _e, _f;
|
|
521
480
|
var zVal = (_b = (_a = firstData.z) === null || _a === void 0 ? void 0 : _a[yIdx]) === null || _b === void 0 ? void 0 : _b[xIdx];
|
|
@@ -569,9 +528,9 @@ var transformPlotlyJsonToHeatmapProps = function (input) {
|
|
|
569
528
|
};
|
|
570
529
|
};
|
|
571
530
|
exports.transformPlotlyJsonToHeatmapProps = transformPlotlyJsonToHeatmapProps;
|
|
572
|
-
var transformPlotlyJsonToSankeyProps = function (input, colorMap, isDarkTheme) {
|
|
573
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
574
|
-
var
|
|
531
|
+
var transformPlotlyJsonToSankeyProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
532
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
533
|
+
var _m = input.data[0], link = _m.link, node = _m.node;
|
|
575
534
|
var validLinks = ((_a = link === null || link === void 0 ? void 0 : link.value) !== null && _a !== void 0 ? _a : [])
|
|
576
535
|
.map(function (val, index) { return ({
|
|
577
536
|
value: val,
|
|
@@ -580,21 +539,23 @@ var transformPlotlyJsonToSankeyProps = function (input, colorMap, isDarkTheme) {
|
|
|
580
539
|
}); })
|
|
581
540
|
// Filter out negative nodes, unequal nodes and self-references (circular links)
|
|
582
541
|
.filter(function (x) { return x.source >= 0 && x.target >= 0 && x.source !== x.target; });
|
|
542
|
+
var extractedNodeColors = (0, PlotlyColorAdapter_1.extractColor)((_d = (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.template) === null || _c === void 0 ? void 0 : _c.layout) === null || _d === void 0 ? void 0 : _d.colorway, colorwayType, node === null || node === void 0 ? void 0 : node.color, colorMap, isDarkTheme);
|
|
583
543
|
var sankeyChartData = {
|
|
584
|
-
nodes: (
|
|
585
|
-
var color = (0,
|
|
544
|
+
nodes: (_e = node.label) === null || _e === void 0 ? void 0 : _e.map(function (label, index) {
|
|
545
|
+
var color = (0, PlotlyColorAdapter_1.resolveColor)(extractedNodeColors, index, label, colorMap, isDarkTheme);
|
|
586
546
|
return {
|
|
587
547
|
nodeId: index,
|
|
588
548
|
name: label,
|
|
589
549
|
color: color,
|
|
590
550
|
};
|
|
591
551
|
}),
|
|
552
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
592
553
|
links: validLinks.map(function (validLink, index) {
|
|
593
554
|
return tslib_1.__assign({}, validLink);
|
|
594
555
|
}),
|
|
595
556
|
};
|
|
596
557
|
var styles = {
|
|
597
|
-
root: tslib_1.__assign({}, (((
|
|
558
|
+
root: tslib_1.__assign({}, (((_g = (_f = input.layout) === null || _f === void 0 ? void 0 : _f.font) === null || _g === void 0 ? void 0 : _g.size) ? { fontSize: (_h = input.layout.font) === null || _h === void 0 ? void 0 : _h.size } : {})),
|
|
598
559
|
};
|
|
599
560
|
var chartTitle = getTitles(input.layout).chartTitle;
|
|
600
561
|
return {
|
|
@@ -602,51 +563,56 @@ var transformPlotlyJsonToSankeyProps = function (input, colorMap, isDarkTheme) {
|
|
|
602
563
|
chartTitle: chartTitle,
|
|
603
564
|
SankeyChartData: sankeyChartData,
|
|
604
565
|
},
|
|
605
|
-
width: (
|
|
606
|
-
height: (
|
|
566
|
+
width: (_j = input.layout) === null || _j === void 0 ? void 0 : _j.width,
|
|
567
|
+
height: (_l = (_k = input.layout) === null || _k === void 0 ? void 0 : _k.height) !== null && _l !== void 0 ? _l : 468,
|
|
607
568
|
styles: styles,
|
|
608
569
|
enableReflow: true,
|
|
609
570
|
};
|
|
610
571
|
};
|
|
611
572
|
exports.transformPlotlyJsonToSankeyProps = transformPlotlyJsonToSankeyProps;
|
|
612
|
-
var transformPlotlyJsonToGaugeProps = function (input, colorMap, isDarkTheme) {
|
|
613
|
-
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;
|
|
573
|
+
var transformPlotlyJsonToGaugeProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
574
|
+
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, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25;
|
|
614
575
|
var firstData = input.data[0];
|
|
615
|
-
var
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
legend
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
576
|
+
var stepsColors = ((_a = firstData.gauge) === null || _a === void 0 ? void 0 : _a.steps) ? firstData.gauge.steps.map(function (step) { return step.color; }) : undefined;
|
|
577
|
+
var extractedColors = (0, PlotlyColorAdapter_1.extractColor)((_d = (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.template) === null || _c === void 0 ? void 0 : _c.layout) === null || _d === void 0 ? void 0 : _d.colorway, colorwayType, stepsColors, colorMap, isDarkTheme);
|
|
578
|
+
var segments = ((_f = (_e = firstData.gauge) === null || _e === void 0 ? void 0 : _e.steps) === null || _f === void 0 ? void 0 : _f.length)
|
|
579
|
+
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
580
|
+
firstData.gauge.steps.map(function (step, index) {
|
|
581
|
+
var _a, _b;
|
|
582
|
+
var legend = step.name || "Segment ".concat(index + 1);
|
|
583
|
+
var color = (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
584
|
+
return {
|
|
585
|
+
legend: legend,
|
|
586
|
+
size: ((_a = step.range) === null || _a === void 0 ? void 0 : _a[1]) - ((_b = step.range) === null || _b === void 0 ? void 0 : _b[0]),
|
|
587
|
+
color: color,
|
|
588
|
+
};
|
|
589
|
+
})
|
|
626
590
|
: [
|
|
627
591
|
{
|
|
628
592
|
legend: 'Current',
|
|
629
|
-
size: (
|
|
630
|
-
color: (0, exports.
|
|
593
|
+
size: (_g = firstData.value) !== null && _g !== void 0 ? _g : 0 - ((_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[0]) !== null && _l !== void 0 ? _l : 0),
|
|
594
|
+
color: (0, exports._getGaugeAxisColor)((_p = (_o = (_m = input.layout) === null || _m === void 0 ? void 0 : _m.template) === null || _o === void 0 ? void 0 : _o.layout) === null || _p === void 0 ? void 0 : _p.colorway, colorwayType, (_r = (_q = firstData.gauge) === null || _q === void 0 ? void 0 : _q.axis) === null || _r === void 0 ? void 0 : _r.color, colorMap, isDarkTheme),
|
|
631
595
|
},
|
|
632
596
|
{
|
|
633
597
|
legend: 'Target',
|
|
634
|
-
size: ((
|
|
598
|
+
size: ((_v = (_u = (_t = (_s = firstData.gauge) === null || _s === void 0 ? void 0 : _s.axis) === null || _t === void 0 ? void 0 : _t.range) === null || _u === void 0 ? void 0 : _u[1]) !== null && _v !== void 0 ? _v : 100) - ((_w = firstData.value) !== null && _w !== void 0 ? _w : 0),
|
|
635
599
|
color: colors_1.DataVizPalette.disabled,
|
|
636
600
|
},
|
|
637
601
|
];
|
|
638
602
|
var sublabel;
|
|
639
603
|
var sublabelColor;
|
|
640
|
-
if ((
|
|
604
|
+
if ((_x = firstData.delta) === null || _x === void 0 ? void 0 : _x.reference) {
|
|
641
605
|
var diff = firstData.value - firstData.delta.reference;
|
|
642
606
|
if (diff >= 0) {
|
|
643
607
|
sublabel = "\u25B2 ".concat(diff);
|
|
644
|
-
var
|
|
608
|
+
var extractedIncreasingDeltaColors = (0, PlotlyColorAdapter_1.extractColor)((_0 = (_z = (_y = input.layout) === null || _y === void 0 ? void 0 : _y.template) === null || _z === void 0 ? void 0 : _z.layout) === null || _0 === void 0 ? void 0 : _0.colorway, colorwayType, (_2 = (_1 = firstData.delta) === null || _1 === void 0 ? void 0 : _1.increasing) === null || _2 === void 0 ? void 0 : _2.color, colorMap, isDarkTheme);
|
|
609
|
+
var color = (0, PlotlyColorAdapter_1.resolveColor)(extractedIncreasingDeltaColors, 0, '', colorMap, isDarkTheme);
|
|
645
610
|
sublabelColor = color;
|
|
646
611
|
}
|
|
647
612
|
else {
|
|
648
613
|
sublabel = "\u25BC ".concat(Math.abs(diff));
|
|
649
|
-
var
|
|
614
|
+
var extractedDecreasingDeltaColors = (0, PlotlyColorAdapter_1.extractColor)((_5 = (_4 = (_3 = input.layout) === null || _3 === void 0 ? void 0 : _3.template) === null || _4 === void 0 ? void 0 : _4.layout) === null || _5 === void 0 ? void 0 : _5.colorway, colorwayType, (_7 = (_6 = firstData.delta) === null || _6 === void 0 ? void 0 : _6.decreasing) === null || _7 === void 0 ? void 0 : _7.color, colorMap, isDarkTheme);
|
|
615
|
+
var color = (0, PlotlyColorAdapter_1.resolveColor)(extractedDecreasingDeltaColors, 0, '', colorMap, isDarkTheme);
|
|
650
616
|
sublabelColor = color;
|
|
651
617
|
}
|
|
652
618
|
}
|
|
@@ -658,20 +624,64 @@ var transformPlotlyJsonToGaugeProps = function (input, colorMap, isDarkTheme) {
|
|
|
658
624
|
var chartTitle = getTitles(input.layout).chartTitle;
|
|
659
625
|
return {
|
|
660
626
|
segments: segments,
|
|
661
|
-
chartValue: (
|
|
627
|
+
chartValue: (_8 = firstData.value) !== null && _8 !== void 0 ? _8 : 0,
|
|
662
628
|
chartTitle: chartTitle,
|
|
663
629
|
sublabel: sublabel,
|
|
664
630
|
// range values can be null
|
|
665
|
-
minValue: typeof ((
|
|
666
|
-
maxValue: typeof ((
|
|
631
|
+
minValue: typeof ((_11 = (_10 = (_9 = firstData.gauge) === null || _9 === void 0 ? void 0 : _9.axis) === null || _10 === void 0 ? void 0 : _10.range) === null || _11 === void 0 ? void 0 : _11[0]) === 'number' ? (_14 = (_13 = (_12 = firstData.gauge) === null || _12 === void 0 ? void 0 : _12.axis) === null || _13 === void 0 ? void 0 : _13.range) === null || _14 === void 0 ? void 0 : _14[0] : undefined,
|
|
632
|
+
maxValue: typeof ((_17 = (_16 = (_15 = firstData.gauge) === null || _15 === void 0 ? void 0 : _15.axis) === null || _16 === void 0 ? void 0 : _16.range) === null || _17 === void 0 ? void 0 : _17[1]) === 'number' ? (_20 = (_19 = (_18 = firstData.gauge) === null || _18 === void 0 ? void 0 : _18.axis) === null || _19 === void 0 ? void 0 : _19.range) === null || _20 === void 0 ? void 0 : _20[1] : undefined,
|
|
667
633
|
chartValueFormat: function () { var _a, _b; return (_b = (_a = firstData.value) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : ''; },
|
|
668
|
-
width: (
|
|
669
|
-
height: (
|
|
634
|
+
width: (_21 = input.layout) === null || _21 === void 0 ? void 0 : _21.width,
|
|
635
|
+
height: (_23 = (_22 = input.layout) === null || _22 === void 0 ? void 0 : _22.height) !== null && _23 !== void 0 ? _23 : 220,
|
|
670
636
|
styles: styles,
|
|
671
|
-
variant: ((
|
|
637
|
+
variant: ((_25 = (_24 = firstData.gauge) === null || _24 === void 0 ? void 0 : _24.steps) === null || _25 === void 0 ? void 0 : _25.length) ? index_1.GaugeChartVariant.MultipleSegments : index_1.GaugeChartVariant.SingleSegment,
|
|
638
|
+
roundCorners: true,
|
|
672
639
|
};
|
|
673
640
|
};
|
|
674
641
|
exports.transformPlotlyJsonToGaugeProps = transformPlotlyJsonToGaugeProps;
|
|
642
|
+
var cleanText = function (text) {
|
|
643
|
+
return text
|
|
644
|
+
.replace(/<[^&]*?>/g, '')
|
|
645
|
+
.replace(/<[^>]*>/g, '')
|
|
646
|
+
.replace(/<br>|\\u003cbr\\u003e|<br>/gi, '')
|
|
647
|
+
.replace(/\$[^$]*\$/g, '$')
|
|
648
|
+
.trim();
|
|
649
|
+
};
|
|
650
|
+
var transformPlotlyJsonToChartTableProps = function (input, colorMap, isDarkTheme) {
|
|
651
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
652
|
+
var tableData = input.data[0];
|
|
653
|
+
var normalizeHeaders = function (values) {
|
|
654
|
+
// Case: values is array of arrays
|
|
655
|
+
if (Array.isArray(values[0])) {
|
|
656
|
+
return values.map(function (row) {
|
|
657
|
+
return row
|
|
658
|
+
.map(function (cell) { return cleanText(cell); })
|
|
659
|
+
.filter(Boolean)
|
|
660
|
+
.join(' ');
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
// Case: values is 1d array
|
|
664
|
+
return values.map(function (cell) { return cleanText(cell); });
|
|
665
|
+
};
|
|
666
|
+
var columns = (_b = (_a = tableData.cells) === null || _a === void 0 ? void 0 : _a.values) !== null && _b !== void 0 ? _b : [];
|
|
667
|
+
var rows = columns[0].map(function (_, rowIndex) {
|
|
668
|
+
return columns.map(function (col) {
|
|
669
|
+
var cell = col[rowIndex];
|
|
670
|
+
return typeof cell === 'string' ? cleanText(cell) : cell;
|
|
671
|
+
});
|
|
672
|
+
});
|
|
673
|
+
var styles = {
|
|
674
|
+
root: tslib_1.__assign({}, (((_d = (_c = input.layout) === null || _c === void 0 ? void 0 : _c.font) === null || _d === void 0 ? void 0 : _d.size) ? { fontSize: input.layout.font.size } : {})),
|
|
675
|
+
};
|
|
676
|
+
return {
|
|
677
|
+
headers: normalizeHeaders((_f = (_e = tableData.header) === null || _e === void 0 ? void 0 : _e.values) !== null && _f !== void 0 ? _f : []),
|
|
678
|
+
rows: rows,
|
|
679
|
+
width: (_g = input.layout) === null || _g === void 0 ? void 0 : _g.width,
|
|
680
|
+
height: (_h = input.layout) === null || _h === void 0 ? void 0 : _h.height,
|
|
681
|
+
styles: styles,
|
|
682
|
+
};
|
|
683
|
+
};
|
|
684
|
+
exports.transformPlotlyJsonToChartTableProps = transformPlotlyJsonToChartTableProps;
|
|
675
685
|
var projectPolarToCartesian = function (input) {
|
|
676
686
|
var projection = tslib_1.__assign({}, input);
|
|
677
687
|
for (var sindex = 0; sindex < input.data.length; sindex++) {
|
|
@@ -689,6 +699,7 @@ var projectPolarToCartesian = function (input) {
|
|
|
689
699
|
return projection;
|
|
690
700
|
};
|
|
691
701
|
exports.projectPolarToCartesian = projectPolarToCartesian;
|
|
702
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
692
703
|
function isPlainObject(obj) {
|
|
693
704
|
if (window && window.process && window.process.versions) {
|
|
694
705
|
return Object.prototype.toString.call(obj) === '[object Object]';
|
|
@@ -696,20 +707,26 @@ function isPlainObject(obj) {
|
|
|
696
707
|
return (Object.prototype.toString.call(obj) === '[object Object]' &&
|
|
697
708
|
Object.getPrototypeOf(obj).hasOwnProperty('hasOwnProperty'));
|
|
698
709
|
}
|
|
710
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
699
711
|
var arrayAttributes = [];
|
|
712
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
700
713
|
var stack = [];
|
|
714
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
701
715
|
var isArrayStack = [];
|
|
716
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
702
717
|
var baseContainer, baseAttrName;
|
|
703
718
|
/**
|
|
704
719
|
* Interate iteratively through the trace object and find all the array attributes.
|
|
705
720
|
* 1 trace record = 1 series of data
|
|
706
721
|
* @param trace
|
|
707
722
|
*/
|
|
723
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
708
724
|
function findArrayAttributes(trace) {
|
|
709
725
|
// Init basecontainer and baseAttrName
|
|
710
726
|
crawlIntoTrace(baseContainer, 0, '');
|
|
711
727
|
}
|
|
712
728
|
exports.findArrayAttributes = findArrayAttributes;
|
|
729
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
713
730
|
function crawlIntoTrace(container, i, astrPartial) {
|
|
714
731
|
var item = container[stack[i]];
|
|
715
732
|
var newAstrPartial = astrPartial + stack[i];
|
|
@@ -760,7 +777,9 @@ function getLineOptions(line) {
|
|
|
760
777
|
}
|
|
761
778
|
return Object.keys(lineOptions).length > 0 ? lineOptions : undefined;
|
|
762
779
|
}
|
|
780
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
763
781
|
var isStringArray = function (arr) {
|
|
782
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
764
783
|
return (0, chart_utilities_1.isArrayOfType)(arr, function (value) { return typeof value === 'string'; });
|
|
765
784
|
};
|
|
766
785
|
// TODO: Use binary search to find the appropriate bin for numeric value.
|