@fluentui/react-charting 5.23.87 → 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 +79 -1
- package/CHANGELOG.md +28 -2
- package/dist/react-charting.d.ts +72 -3
- 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 -3
- package/lib/components/DeclarativeChart/DeclarativeChart.js +15 -11
- 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 -11
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +155 -113
- 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 -3
- package/lib-amd/components/DeclarativeChart/DeclarativeChart.js +14 -11
- 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 -11
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +157 -115
- 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 -3
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +14 -10
- 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 -11
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +157 -115
- 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 +5 -5
- package/src/components/ChartTable/ChartTable.types.ts +68 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { __assign } from "tslib";
|
|
2
2
|
import { bin as d3Bin, extent as d3Extent, sum as d3Sum, min as d3Min, max as d3Max, range as d3Range, } from 'd3-array';
|
|
3
3
|
import { scaleLinear as d3ScaleLinear } from 'd3-scale';
|
|
4
|
-
import { DataVizPalette, getColorFromToken
|
|
4
|
+
import { DataVizPalette, getColorFromToken } from '../../utilities/colors';
|
|
5
5
|
import { GaugeChartVariant } from '../GaugeChart/index';
|
|
6
6
|
import { findNumericMinMaxOfY } from '../../utilities/utilities';
|
|
7
7
|
import { isArrayOfType, isArrayOrTypedArray, isDate, isDateArray, isNumberArray, isYearArray, } from '@fluentui/chart-utilities';
|
|
8
8
|
import { timeParse } from 'd3-time-format';
|
|
9
9
|
import { curveCardinal as d3CurveCardinal } from 'd3-shape';
|
|
10
|
-
import {
|
|
10
|
+
import { extractColor, resolveColor } from './PlotlyColorAdapter';
|
|
11
11
|
var dashOptions = {
|
|
12
12
|
dot: {
|
|
13
13
|
strokeDasharray: '1, 5',
|
|
@@ -46,6 +46,7 @@ var dashOptions = {
|
|
|
46
46
|
lineBorderWidth: '4',
|
|
47
47
|
},
|
|
48
48
|
};
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
50
|
var isMonth = function (possiblyMonthValue) {
|
|
50
51
|
var parseFullMonth = timeParse('%B');
|
|
51
52
|
var parseShortMonth = timeParse('%b');
|
|
@@ -63,6 +64,7 @@ function getTitles(layout) {
|
|
|
63
64
|
};
|
|
64
65
|
return titles;
|
|
65
66
|
}
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
66
68
|
export var correctYearMonth = function (xValues) {
|
|
67
69
|
var presentYear = new Date().getFullYear();
|
|
68
70
|
if (xValues.length > 0 && Array.isArray(xValues[0])) {
|
|
@@ -89,14 +91,6 @@ export var correctYearMonth = function (xValues) {
|
|
|
89
91
|
});
|
|
90
92
|
return xValues;
|
|
91
93
|
};
|
|
92
|
-
export var getColor = function (legendLabel, colorMap, isDarkTheme) {
|
|
93
|
-
if (!colorMap.current.has(legendLabel)) {
|
|
94
|
-
var nextColor = getNextColor(colorMap.current.size + 1, 0, isDarkTheme);
|
|
95
|
-
colorMap.current.set(legendLabel, nextColor);
|
|
96
|
-
return nextColor;
|
|
97
|
-
}
|
|
98
|
-
return colorMap.current.get(legendLabel);
|
|
99
|
-
};
|
|
100
94
|
var usesSecondaryYScale = function (series) {
|
|
101
95
|
return series.yaxis === 'y2';
|
|
102
96
|
};
|
|
@@ -140,50 +134,20 @@ var getSecondaryYAxisValues = function (data, layout, maxAllowedMinY, minAllowed
|
|
|
140
134
|
},
|
|
141
135
|
};
|
|
142
136
|
};
|
|
143
|
-
export var
|
|
144
|
-
var
|
|
145
|
-
|
|
146
|
-
return undefined;
|
|
147
|
-
}
|
|
148
|
-
if (isArrayOrTypedArray(colors)) {
|
|
149
|
-
colors.forEach(function (element, index) {
|
|
150
|
-
var colorString = element === null || element === void 0 ? void 0 : element.toString().trim();
|
|
151
|
-
var nextFluentColor = getColor("Label_".concat(index), colorMap, isDarkTheme);
|
|
152
|
-
if (colorString) {
|
|
153
|
-
var parsedColor = d3Color(colorString);
|
|
154
|
-
hexColors.push(parsedColor ? parsedColor.formatHex() : nextFluentColor);
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
hexColors.push(nextFluentColor);
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
else if (typeof colors === 'string') {
|
|
162
|
-
var parsedColor = d3Color(colors);
|
|
163
|
-
return parsedColor ? parsedColor.formatHex() : getColor('Label_0', colorMap, isDarkTheme);
|
|
164
|
-
}
|
|
165
|
-
return hexColors;
|
|
137
|
+
export var _getGaugeAxisColor = function (colorway, colorwayType, color, colorMap, isDarkTheme) {
|
|
138
|
+
var extractedColors = extractColor(colorway, colorwayType, color, colorMap, isDarkTheme);
|
|
139
|
+
return resolveColor(extractedColors, 0, '', colorMap, isDarkTheme);
|
|
166
140
|
};
|
|
167
|
-
export var transformPlotlyJsonToDonutProps = function (input, colorMap,
|
|
168
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
141
|
+
export var transformPlotlyJsonToDonutProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
142
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
169
143
|
var firstData = input.data[0];
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
colors = ((_a = firstData.marker) === null || _a === void 0 ? void 0 : _a.colors) ? getSchemaColors((_b = firstData === null || firstData === void 0 ? void 0 : firstData.marker) === null || _b === void 0 ? void 0 : _b.colors, colorMap, isDarkTheme) : undefined;
|
|
173
|
-
}
|
|
144
|
+
// extract colors for each series only once
|
|
145
|
+
var colors = 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);
|
|
174
146
|
var mapLegendToDataPoint = {};
|
|
175
|
-
(
|
|
147
|
+
(_e = firstData.labels) === null || _e === void 0 ? void 0 : _e.forEach(function (label, index) {
|
|
176
148
|
var _a;
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
color = colors[index % colors.length];
|
|
180
|
-
}
|
|
181
|
-
else if (typeof colors === 'string') {
|
|
182
|
-
color = colors;
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
color = getColor(label, colorMap, isDarkTheme);
|
|
186
|
-
}
|
|
149
|
+
// resolve color for each legend from the extracted colors
|
|
150
|
+
var color = resolveColor(colors, index, label, colorMap, isDarkTheme);
|
|
187
151
|
//ToDo how to handle string data?
|
|
188
152
|
var value = typeof ((_a = firstData.values) === null || _a === void 0 ? void 0 : _a[index]) === 'number' ? firstData.values[index] : 1;
|
|
189
153
|
if (!mapLegendToDataPoint[label]) {
|
|
@@ -197,8 +161,8 @@ export var transformPlotlyJsonToDonutProps = function (input, colorMap, useFluen
|
|
|
197
161
|
mapLegendToDataPoint[label].data += value;
|
|
198
162
|
}
|
|
199
163
|
});
|
|
200
|
-
var width = (
|
|
201
|
-
var height = (
|
|
164
|
+
var width = (_g = (_f = input.layout) === null || _f === void 0 ? void 0 : _f.width) !== null && _g !== void 0 ? _g : 440;
|
|
165
|
+
var height = (_j = (_h = input.layout) === null || _h === void 0 ? void 0 : _h.height) !== null && _j !== void 0 ? _j : 220;
|
|
202
166
|
var hideLabels = firstData.textinfo
|
|
203
167
|
? !['value', 'percent', 'label+percent'].includes(firstData.textinfo)
|
|
204
168
|
: false;
|
|
@@ -213,32 +177,38 @@ export var transformPlotlyJsonToDonutProps = function (input, colorMap, useFluen
|
|
|
213
177
|
chartTitle: chartTitle,
|
|
214
178
|
chartData: Object.values(mapLegendToDataPoint),
|
|
215
179
|
},
|
|
216
|
-
hideLegend: ((
|
|
217
|
-
width: (
|
|
180
|
+
hideLegend: ((_k = input.layout) === null || _k === void 0 ? void 0 : _k.showlegend) === false ? true : false,
|
|
181
|
+
width: (_l = input.layout) === null || _l === void 0 ? void 0 : _l.width,
|
|
218
182
|
height: height,
|
|
219
183
|
innerRadius: innerRadius,
|
|
220
184
|
hideLabels: hideLabels,
|
|
221
185
|
showLabelsInPercent: firstData.textinfo ? ['percent', 'label+percent'].includes(firstData.textinfo) : true,
|
|
186
|
+
roundCorners: true,
|
|
222
187
|
};
|
|
223
188
|
};
|
|
224
|
-
export var transformPlotlyJsonToVSBCProps = function (input, colorMap, isDarkTheme, fallbackVSBC) {
|
|
189
|
+
export var transformPlotlyJsonToVSBCProps = function (input, colorMap, colorwayType, isDarkTheme, fallbackVSBC) {
|
|
225
190
|
var _a, _b, _c;
|
|
226
191
|
var mapXToDataPoints = {};
|
|
227
192
|
var yMaxValue = 0;
|
|
228
193
|
var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
|
|
229
194
|
var _d = getLegendProps(input.data, input.layout), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
230
195
|
input.data.forEach(function (series, index1) {
|
|
231
|
-
var _a;
|
|
196
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
232
197
|
var isXYearCategory = isYearArray(series.x); // Consider year as categorical not numeric continuous axis
|
|
233
|
-
|
|
198
|
+
// extract bar colors for each series only once
|
|
199
|
+
var extractedBarColors = 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);
|
|
200
|
+
// extract line colors for each series only once
|
|
201
|
+
var extractedLineColors = 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);
|
|
202
|
+
(_j = series.x) === null || _j === void 0 ? void 0 : _j.forEach(function (x, index2) {
|
|
234
203
|
var _a, _b, _c;
|
|
235
204
|
if (!mapXToDataPoints[x]) {
|
|
236
205
|
mapXToDataPoints[x] = { xAxisPoint: isXYearCategory ? x.toString() : x, chartData: [], lineData: [] };
|
|
237
206
|
}
|
|
238
207
|
var legend = legends[index1];
|
|
208
|
+
// resolve color for each legend's bars from the extracted colors
|
|
209
|
+
var color = resolveColor(extractedBarColors, index1, legend, colorMap, isDarkTheme);
|
|
239
210
|
var yVal = (_b = (_a = series.y) === null || _a === void 0 ? void 0 : _a[index2]) !== null && _b !== void 0 ? _b : 0;
|
|
240
211
|
if (series.type === 'bar') {
|
|
241
|
-
var color = getColor(legend, colorMap, isDarkTheme);
|
|
242
212
|
mapXToDataPoints[x].chartData.push({
|
|
243
213
|
legend: legend,
|
|
244
214
|
data: yVal,
|
|
@@ -247,11 +217,11 @@ export var transformPlotlyJsonToVSBCProps = function (input, colorMap, isDarkThe
|
|
|
247
217
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
248
218
|
}
|
|
249
219
|
else if (series.type === 'scatter' || !!fallbackVSBC) {
|
|
250
|
-
var
|
|
220
|
+
var lineColor = resolveColor(extractedLineColors, index1, legend, colorMap, isDarkTheme);
|
|
251
221
|
var lineOptions = getLineOptions(series.line);
|
|
252
222
|
var dashType = ((_c = series.line) === null || _c === void 0 ? void 0 : _c.dash) || 'solid';
|
|
253
223
|
var legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot' ? 'dottedLine' : 'default';
|
|
254
|
-
mapXToDataPoints[x].lineData.push(__assign(__assign({ legend: legend, legendShape: legendShape, y: yVal, color:
|
|
224
|
+
mapXToDataPoints[x].lineData.push(__assign(__assign({ legend: legend, legendShape: legendShape, y: yVal, color: lineColor }, (lineOptions ? { lineOptions: lineOptions } : {})), { useSecondaryYScale: usesSecondaryYScale(series) }));
|
|
255
225
|
if (!usesSecondaryYScale(series)) {
|
|
256
226
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
257
227
|
}
|
|
@@ -259,23 +229,26 @@ export var transformPlotlyJsonToVSBCProps = function (input, colorMap, isDarkThe
|
|
|
259
229
|
});
|
|
260
230
|
});
|
|
261
231
|
var _e = getTitles(input.layout), chartTitle = _e.chartTitle, xAxisTitle = _e.xAxisTitle, yAxisTitle = _e.yAxisTitle;
|
|
262
|
-
return __assign(__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 });
|
|
232
|
+
return __assign(__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 });
|
|
263
233
|
};
|
|
264
|
-
export var transformPlotlyJsonToGVBCProps = function (input, colorMap, isDarkTheme) {
|
|
234
|
+
export var transformPlotlyJsonToGVBCProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
265
235
|
var _a, _b, _c;
|
|
266
236
|
var mapXToDataPoints = {};
|
|
267
237
|
var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, 0, 0);
|
|
268
238
|
var _d = getLegendProps(input.data, input.layout), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
269
239
|
input.data.forEach(function (series, index1) {
|
|
270
|
-
var _a;
|
|
271
|
-
|
|
240
|
+
var _a, _b, _c, _d, _e;
|
|
241
|
+
// extract colors for each series only once
|
|
242
|
+
var extractedColors = 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);
|
|
243
|
+
(_e = series.x) === null || _e === void 0 ? void 0 : _e.forEach(function (x, xIndex) {
|
|
272
244
|
var _a, _b;
|
|
273
245
|
if (!mapXToDataPoints[x]) {
|
|
274
246
|
mapXToDataPoints[x] = { name: x.toString(), series: [] };
|
|
275
247
|
}
|
|
276
248
|
if (series.type === 'bar') {
|
|
277
249
|
var legend = legends[index1];
|
|
278
|
-
|
|
250
|
+
// resolve color for each legend's bars from the extracted colors
|
|
251
|
+
var color = resolveColor(extractedColors, index1, legend, colorMap, isDarkTheme);
|
|
279
252
|
mapXToDataPoints[x].series.push({
|
|
280
253
|
key: legend,
|
|
281
254
|
data: (_b = (_a = series.y) === null || _a === void 0 ? void 0 : _a[xIndex]) !== null && _b !== void 0 ? _b : 0,
|
|
@@ -288,21 +261,23 @@ export var transformPlotlyJsonToGVBCProps = function (input, colorMap, isDarkThe
|
|
|
288
261
|
});
|
|
289
262
|
});
|
|
290
263
|
var _e = getTitles(input.layout), chartTitle = _e.chartTitle, xAxisTitle = _e.xAxisTitle, yAxisTitle = _e.yAxisTitle;
|
|
291
|
-
return __assign(__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 });
|
|
264
|
+
return __assign(__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 });
|
|
292
265
|
};
|
|
293
|
-
export var transformPlotlyJsonToVBCProps = function (input, colorMap, isDarkTheme) {
|
|
266
|
+
export var transformPlotlyJsonToVBCProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
294
267
|
var _a, _b, _c;
|
|
295
268
|
var vbcData = [];
|
|
296
269
|
var _d = getLegendProps(input.data, input.layout), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
297
270
|
input.data.forEach(function (series, seriesIdx) {
|
|
298
|
-
var _a, _b, _c;
|
|
271
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
299
272
|
if (!series.x) {
|
|
300
273
|
return;
|
|
301
274
|
}
|
|
275
|
+
// extract colors for each series only once
|
|
276
|
+
var extractedColors = 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);
|
|
302
277
|
var isXString = isStringArray(series.x);
|
|
303
278
|
// TODO: In case of a single bin, add an empty bin of the same size to prevent the
|
|
304
279
|
// default bar width from being used and ensure the bar spans the full intended range.
|
|
305
|
-
var xBins = createBins(series.x, (
|
|
280
|
+
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);
|
|
306
281
|
var yBins = xBins.map(function () { return []; });
|
|
307
282
|
var total = 0;
|
|
308
283
|
series.x.forEach(function (xVal, index) {
|
|
@@ -319,7 +294,8 @@ export var transformPlotlyJsonToVBCProps = function (input, colorMap, isDarkThem
|
|
|
319
294
|
});
|
|
320
295
|
xBins.forEach(function (bin, index) {
|
|
321
296
|
var legend = legends[seriesIdx];
|
|
322
|
-
|
|
297
|
+
// resolve color for each legend's bars from the extracted colors
|
|
298
|
+
var color = resolveColor(extractedColors, seriesIdx, legend, colorMap, isDarkTheme);
|
|
323
299
|
var yVal = calculateHistNorm(series.histnorm, y[index], total, isXString ? bin.length : getBinSize(bin));
|
|
324
300
|
vbcData.push(__assign({ x: isXString ? bin.join(', ') : getBinCenter(bin), y: yVal, legend: legend, color: color }, (isXString
|
|
325
301
|
? {}
|
|
@@ -339,26 +315,28 @@ export var transformPlotlyJsonToVBCProps = function (input, colorMap, isDarkThem
|
|
|
339
315
|
hideTickOverlap: true,
|
|
340
316
|
maxBarWidth: 50,
|
|
341
317
|
hideLegend: hideLegend,
|
|
318
|
+
roundCorners: true,
|
|
342
319
|
};
|
|
343
320
|
};
|
|
344
|
-
export var transformPlotlyJsonToScatterChartProps = function (input, isAreaChart, colorMap,
|
|
321
|
+
export var transformPlotlyJsonToScatterChartProps = function (input, isAreaChart, isScatterMarkers, colorMap, colorwayType, isDarkTheme) {
|
|
345
322
|
var _a, _b, _c, _d, _e, _f;
|
|
346
323
|
var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
|
|
347
324
|
var mode = 'tonexty';
|
|
348
325
|
var _g = getLegendProps(input.data, input.layout), legends = _g.legends, hideLegend = _g.hideLegend;
|
|
349
326
|
var chartData = input.data.map(function (series, index) {
|
|
350
|
-
var _a, _b, _c;
|
|
327
|
+
var _a, _b, _c, _d, _e, _f;
|
|
328
|
+
// extract colors for each series only once
|
|
329
|
+
var extractedColors = 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);
|
|
351
330
|
var xValues = series.x;
|
|
352
331
|
var isString = typeof xValues[0] === 'string';
|
|
353
332
|
var isXDate = isDateArray(xValues);
|
|
354
333
|
var isXNumber = isNumberArray(xValues);
|
|
355
334
|
var legend = legends[index];
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
: getColor(legend, colorMap, isDarkTheme);
|
|
335
|
+
// resolve color for each legend's lines from the extracted colors
|
|
336
|
+
var seriesColor = resolveColor(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
359
337
|
mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
|
|
360
338
|
var lineOptions = getLineOptions(series.line);
|
|
361
|
-
var dashType = ((
|
|
339
|
+
var dashType = ((_f = series.line) === null || _f === void 0 ? void 0 : _f.dash) || 'solid';
|
|
362
340
|
var legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot' ? 'dottedLine' : 'default';
|
|
363
341
|
return __assign(__assign({ legend: legend, legendShape: legendShape, data: xValues.map(function (x, i) {
|
|
364
342
|
var _a, _b;
|
|
@@ -367,7 +345,7 @@ export var transformPlotlyJsonToScatterChartProps = function (input, isAreaChart
|
|
|
367
345
|
: typeof ((_b = series.marker) === null || _b === void 0 ? void 0 : _b.size) === 'number'
|
|
368
346
|
? { markerSize: series.marker.size }
|
|
369
347
|
: {})));
|
|
370
|
-
}), color:
|
|
348
|
+
}), color: seriesColor }, (lineOptions ? { lineOptions: lineOptions } : {})), { useSecondaryYScale: usesSecondaryYScale(series) });
|
|
371
349
|
});
|
|
372
350
|
var yMinMaxValues = findNumericMinMaxOfY(chartData);
|
|
373
351
|
var _h = getTitles(input.layout), chartTitle = _h.chartTitle, xAxisTitle = _h.xAxisTitle, yAxisTitle = _h.yAxisTitle;
|
|
@@ -382,13 +360,17 @@ export var transformPlotlyJsonToScatterChartProps = function (input, isAreaChart
|
|
|
382
360
|
return __assign(__assign({ data: chartProps, supportNegativeData: true, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle }, secondaryYAxisValues), { roundedTicks: true, yMinValue: yMinMaxValues.startValue, yMaxValue: yMinMaxValues.endValue, width: (_d = input.layout) === null || _d === void 0 ? void 0 : _d.width, height: (_f = (_e = input.layout) === null || _e === void 0 ? void 0 : _e.height) !== null && _f !== void 0 ? _f : 350, hideTickOverlap: true, enableReflow: false, hideLegend: hideLegend, useUTC: false });
|
|
383
361
|
}
|
|
384
362
|
};
|
|
385
|
-
export var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, colorMap, isDarkTheme) {
|
|
363
|
+
export var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
386
364
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
387
365
|
var _s = getLegendProps(input.data, input.layout), legends = _s.legends, hideLegend = _s.hideLegend;
|
|
388
366
|
var chartData = input.data
|
|
389
367
|
.map(function (series, index) {
|
|
368
|
+
var _a, _b, _c, _d;
|
|
369
|
+
// extract colors for each series only once
|
|
370
|
+
var extractedColors = 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);
|
|
390
371
|
var legend = legends[index];
|
|
391
|
-
|
|
372
|
+
// resolve color for each legend's bars from the extracted colors
|
|
373
|
+
var color = resolveColor(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
392
374
|
return series.y.map(function (yValue, i) {
|
|
393
375
|
return {
|
|
394
376
|
x: series.x[i],
|
|
@@ -430,6 +412,7 @@ export var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, co
|
|
|
430
412
|
hideLegend: hideLegend,
|
|
431
413
|
noOfCharsToTruncate: 20,
|
|
432
414
|
showYAxisLablesTooltip: true,
|
|
415
|
+
roundCorners: true,
|
|
433
416
|
};
|
|
434
417
|
};
|
|
435
418
|
export var transformPlotlyJsonToHeatmapProps = function (input) {
|
|
@@ -479,6 +462,7 @@ export var transformPlotlyJsonToHeatmapProps = function (input) {
|
|
|
479
462
|
else {
|
|
480
463
|
(_h = firstData.x) === null || _h === void 0 ? void 0 : _h.forEach(function (xVal, xIdx) {
|
|
481
464
|
var _a;
|
|
465
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
482
466
|
(_a = firstData.y) === null || _a === void 0 ? void 0 : _a.forEach(function (yVal, yIdx) {
|
|
483
467
|
var _a, _b, _c, _d, _e, _f;
|
|
484
468
|
var zVal = (_b = (_a = firstData.z) === null || _a === void 0 ? void 0 : _a[yIdx]) === null || _b === void 0 ? void 0 : _b[xIdx];
|
|
@@ -531,33 +515,34 @@ export var transformPlotlyJsonToHeatmapProps = function (input) {
|
|
|
531
515
|
showYAxisLablesTooltip: true,
|
|
532
516
|
};
|
|
533
517
|
};
|
|
534
|
-
export var transformPlotlyJsonToSankeyProps = function (input, colorMap, isDarkTheme) {
|
|
535
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
536
|
-
var
|
|
518
|
+
export var transformPlotlyJsonToSankeyProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
519
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
520
|
+
var _m = input.data[0], link = _m.link, node = _m.node;
|
|
537
521
|
var validLinks = ((_a = link === null || link === void 0 ? void 0 : link.value) !== null && _a !== void 0 ? _a : [])
|
|
538
522
|
.map(function (val, index) { return ({
|
|
539
523
|
value: val,
|
|
540
524
|
source: link === null || link === void 0 ? void 0 : link.source[index],
|
|
541
525
|
target: link === null || link === void 0 ? void 0 : link.target[index],
|
|
542
526
|
}); })
|
|
543
|
-
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
544
527
|
// Filter out negative nodes, unequal nodes and self-references (circular links)
|
|
545
528
|
.filter(function (x) { return x.source >= 0 && x.target >= 0 && x.source !== x.target; });
|
|
529
|
+
var extractedNodeColors = 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);
|
|
546
530
|
var sankeyChartData = {
|
|
547
|
-
nodes: (
|
|
548
|
-
var color =
|
|
531
|
+
nodes: (_e = node.label) === null || _e === void 0 ? void 0 : _e.map(function (label, index) {
|
|
532
|
+
var color = resolveColor(extractedNodeColors, index, label, colorMap, isDarkTheme);
|
|
549
533
|
return {
|
|
550
534
|
nodeId: index,
|
|
551
535
|
name: label,
|
|
552
536
|
color: color,
|
|
553
537
|
};
|
|
554
538
|
}),
|
|
539
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
555
540
|
links: validLinks.map(function (validLink, index) {
|
|
556
541
|
return __assign({}, validLink);
|
|
557
542
|
}),
|
|
558
543
|
};
|
|
559
544
|
var styles = {
|
|
560
|
-
root: __assign({}, (((
|
|
545
|
+
root: __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 } : {})),
|
|
561
546
|
};
|
|
562
547
|
var chartTitle = getTitles(input.layout).chartTitle;
|
|
563
548
|
return {
|
|
@@ -565,50 +550,55 @@ export var transformPlotlyJsonToSankeyProps = function (input, colorMap, isDarkT
|
|
|
565
550
|
chartTitle: chartTitle,
|
|
566
551
|
SankeyChartData: sankeyChartData,
|
|
567
552
|
},
|
|
568
|
-
width: (
|
|
569
|
-
height: (
|
|
553
|
+
width: (_j = input.layout) === null || _j === void 0 ? void 0 : _j.width,
|
|
554
|
+
height: (_l = (_k = input.layout) === null || _k === void 0 ? void 0 : _k.height) !== null && _l !== void 0 ? _l : 468,
|
|
570
555
|
styles: styles,
|
|
571
556
|
enableReflow: true,
|
|
572
557
|
};
|
|
573
558
|
};
|
|
574
|
-
export var transformPlotlyJsonToGaugeProps = function (input, colorMap, isDarkTheme) {
|
|
575
|
-
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;
|
|
559
|
+
export var transformPlotlyJsonToGaugeProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
560
|
+
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;
|
|
576
561
|
var firstData = input.data[0];
|
|
577
|
-
var
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
legend
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
562
|
+
var stepsColors = ((_a = firstData.gauge) === null || _a === void 0 ? void 0 : _a.steps) ? firstData.gauge.steps.map(function (step) { return step.color; }) : undefined;
|
|
563
|
+
var extractedColors = 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);
|
|
564
|
+
var segments = ((_f = (_e = firstData.gauge) === null || _e === void 0 ? void 0 : _e.steps) === null || _f === void 0 ? void 0 : _f.length)
|
|
565
|
+
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
566
|
+
firstData.gauge.steps.map(function (step, index) {
|
|
567
|
+
var _a, _b;
|
|
568
|
+
var legend = step.name || "Segment ".concat(index + 1);
|
|
569
|
+
var color = resolveColor(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
570
|
+
return {
|
|
571
|
+
legend: legend,
|
|
572
|
+
size: ((_a = step.range) === null || _a === void 0 ? void 0 : _a[1]) - ((_b = step.range) === null || _b === void 0 ? void 0 : _b[0]),
|
|
573
|
+
color: color,
|
|
574
|
+
};
|
|
575
|
+
})
|
|
588
576
|
: [
|
|
589
577
|
{
|
|
590
578
|
legend: 'Current',
|
|
591
|
-
size: (
|
|
592
|
-
color:
|
|
579
|
+
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),
|
|
580
|
+
color: _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),
|
|
593
581
|
},
|
|
594
582
|
{
|
|
595
583
|
legend: 'Target',
|
|
596
|
-
size: ((
|
|
584
|
+
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),
|
|
597
585
|
color: DataVizPalette.disabled,
|
|
598
586
|
},
|
|
599
587
|
];
|
|
600
588
|
var sublabel;
|
|
601
589
|
var sublabelColor;
|
|
602
|
-
if ((
|
|
590
|
+
if ((_x = firstData.delta) === null || _x === void 0 ? void 0 : _x.reference) {
|
|
603
591
|
var diff = firstData.value - firstData.delta.reference;
|
|
604
592
|
if (diff >= 0) {
|
|
605
593
|
sublabel = "\u25B2 ".concat(diff);
|
|
606
|
-
var
|
|
594
|
+
var extractedIncreasingDeltaColors = 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);
|
|
595
|
+
var color = resolveColor(extractedIncreasingDeltaColors, 0, '', colorMap, isDarkTheme);
|
|
607
596
|
sublabelColor = color;
|
|
608
597
|
}
|
|
609
598
|
else {
|
|
610
599
|
sublabel = "\u25BC ".concat(Math.abs(diff));
|
|
611
|
-
var
|
|
600
|
+
var extractedDecreasingDeltaColors = 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);
|
|
601
|
+
var color = resolveColor(extractedDecreasingDeltaColors, 0, '', colorMap, isDarkTheme);
|
|
612
602
|
sublabelColor = color;
|
|
613
603
|
}
|
|
614
604
|
}
|
|
@@ -620,17 +610,60 @@ export var transformPlotlyJsonToGaugeProps = function (input, colorMap, isDarkTh
|
|
|
620
610
|
var chartTitle = getTitles(input.layout).chartTitle;
|
|
621
611
|
return {
|
|
622
612
|
segments: segments,
|
|
623
|
-
chartValue: (
|
|
613
|
+
chartValue: (_8 = firstData.value) !== null && _8 !== void 0 ? _8 : 0,
|
|
624
614
|
chartTitle: chartTitle,
|
|
625
615
|
sublabel: sublabel,
|
|
626
616
|
// range values can be null
|
|
627
|
-
minValue: typeof ((
|
|
628
|
-
maxValue: typeof ((
|
|
617
|
+
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,
|
|
618
|
+
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,
|
|
629
619
|
chartValueFormat: function () { var _a, _b; return (_b = (_a = firstData.value) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : ''; },
|
|
630
|
-
width: (
|
|
631
|
-
height: (
|
|
620
|
+
width: (_21 = input.layout) === null || _21 === void 0 ? void 0 : _21.width,
|
|
621
|
+
height: (_23 = (_22 = input.layout) === null || _22 === void 0 ? void 0 : _22.height) !== null && _23 !== void 0 ? _23 : 220,
|
|
622
|
+
styles: styles,
|
|
623
|
+
variant: ((_25 = (_24 = firstData.gauge) === null || _24 === void 0 ? void 0 : _24.steps) === null || _25 === void 0 ? void 0 : _25.length) ? GaugeChartVariant.MultipleSegments : GaugeChartVariant.SingleSegment,
|
|
624
|
+
roundCorners: true,
|
|
625
|
+
};
|
|
626
|
+
};
|
|
627
|
+
var cleanText = function (text) {
|
|
628
|
+
return text
|
|
629
|
+
.replace(/<[^&]*?>/g, '')
|
|
630
|
+
.replace(/<[^>]*>/g, '')
|
|
631
|
+
.replace(/<br>|\\u003cbr\\u003e|<br>/gi, '')
|
|
632
|
+
.replace(/\$[^$]*\$/g, '$')
|
|
633
|
+
.trim();
|
|
634
|
+
};
|
|
635
|
+
export var transformPlotlyJsonToChartTableProps = function (input, colorMap, isDarkTheme) {
|
|
636
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
637
|
+
var tableData = input.data[0];
|
|
638
|
+
var normalizeHeaders = function (values) {
|
|
639
|
+
// Case: values is array of arrays
|
|
640
|
+
if (Array.isArray(values[0])) {
|
|
641
|
+
return values.map(function (row) {
|
|
642
|
+
return row
|
|
643
|
+
.map(function (cell) { return cleanText(cell); })
|
|
644
|
+
.filter(Boolean)
|
|
645
|
+
.join(' ');
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
// Case: values is 1d array
|
|
649
|
+
return values.map(function (cell) { return cleanText(cell); });
|
|
650
|
+
};
|
|
651
|
+
var columns = (_b = (_a = tableData.cells) === null || _a === void 0 ? void 0 : _a.values) !== null && _b !== void 0 ? _b : [];
|
|
652
|
+
var rows = columns[0].map(function (_, rowIndex) {
|
|
653
|
+
return columns.map(function (col) {
|
|
654
|
+
var cell = col[rowIndex];
|
|
655
|
+
return typeof cell === 'string' ? cleanText(cell) : cell;
|
|
656
|
+
});
|
|
657
|
+
});
|
|
658
|
+
var styles = {
|
|
659
|
+
root: __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 } : {})),
|
|
660
|
+
};
|
|
661
|
+
return {
|
|
662
|
+
headers: normalizeHeaders((_f = (_e = tableData.header) === null || _e === void 0 ? void 0 : _e.values) !== null && _f !== void 0 ? _f : []),
|
|
663
|
+
rows: rows,
|
|
664
|
+
width: (_g = input.layout) === null || _g === void 0 ? void 0 : _g.width,
|
|
665
|
+
height: (_h = input.layout) === null || _h === void 0 ? void 0 : _h.height,
|
|
632
666
|
styles: styles,
|
|
633
|
-
variant: ((_6 = (_5 = firstData.gauge) === null || _5 === void 0 ? void 0 : _5.steps) === null || _6 === void 0 ? void 0 : _6.length) ? GaugeChartVariant.MultipleSegments : GaugeChartVariant.SingleSegment,
|
|
634
667
|
};
|
|
635
668
|
};
|
|
636
669
|
export var projectPolarToCartesian = function (input) {
|
|
@@ -649,6 +682,7 @@ export var projectPolarToCartesian = function (input) {
|
|
|
649
682
|
}
|
|
650
683
|
return projection;
|
|
651
684
|
};
|
|
685
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
652
686
|
function isPlainObject(obj) {
|
|
653
687
|
if (window && window.process && window.process.versions) {
|
|
654
688
|
return Object.prototype.toString.call(obj) === '[object Object]';
|
|
@@ -656,19 +690,25 @@ function isPlainObject(obj) {
|
|
|
656
690
|
return (Object.prototype.toString.call(obj) === '[object Object]' &&
|
|
657
691
|
Object.getPrototypeOf(obj).hasOwnProperty('hasOwnProperty'));
|
|
658
692
|
}
|
|
693
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
659
694
|
var arrayAttributes = [];
|
|
695
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
660
696
|
var stack = [];
|
|
697
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
661
698
|
var isArrayStack = [];
|
|
699
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
662
700
|
var baseContainer, baseAttrName;
|
|
663
701
|
/**
|
|
664
702
|
* Interate iteratively through the trace object and find all the array attributes.
|
|
665
703
|
* 1 trace record = 1 series of data
|
|
666
704
|
* @param trace
|
|
667
705
|
*/
|
|
706
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
668
707
|
export function findArrayAttributes(trace) {
|
|
669
708
|
// Init basecontainer and baseAttrName
|
|
670
709
|
crawlIntoTrace(baseContainer, 0, '');
|
|
671
710
|
}
|
|
711
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
672
712
|
function crawlIntoTrace(container, i, astrPartial) {
|
|
673
713
|
var item = container[stack[i]];
|
|
674
714
|
var newAstrPartial = astrPartial + stack[i];
|
|
@@ -719,7 +759,9 @@ function getLineOptions(line) {
|
|
|
719
759
|
}
|
|
720
760
|
return Object.keys(lineOptions).length > 0 ? lineOptions : undefined;
|
|
721
761
|
}
|
|
762
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
722
763
|
var isStringArray = function (arr) {
|
|
764
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
723
765
|
return isArrayOfType(arr, function (value) { return typeof value === 'string'; });
|
|
724
766
|
};
|
|
725
767
|
// TODO: Use binary search to find the appropriate bin for numeric value.
|