@fluentui/react-charting 5.23.90 → 5.23.92
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 +55 -1
- package/CHANGELOG.md +24 -2
- package/dist/react-charting.d.ts +7 -3
- package/dist/react-charting.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/etc/react-charting.api.md +3 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +9 -2
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +4 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +214 -85
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/LineChart/LineChart.base.d.ts +2 -0
- package/lib/components/LineChart/LineChart.base.js +58 -17
- package/lib/components/LineChart/LineChart.base.js.map +1 -1
- package/lib/components/LineChart/LineChart.types.d.ts +1 -1
- package/lib/components/LineChart/LineChart.types.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.d.ts +2 -2
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
- package/lib/types/IDataPoint.d.ts +4 -0
- package/lib/types/IDataPoint.js.map +1 -1
- package/lib/utilities/image-export-utils.js +18 -1
- package/lib/utilities/image-export-utils.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/DeclarativeChart.js +9 -2
- package/lib-amd/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +4 -1
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +218 -86
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-amd/components/LineChart/LineChart.base.d.ts +2 -0
- package/lib-amd/components/LineChart/LineChart.base.js +58 -17
- package/lib-amd/components/LineChart/LineChart.base.js.map +1 -1
- package/lib-amd/components/LineChart/LineChart.types.d.ts +1 -1
- package/lib-amd/components/LineChart/LineChart.types.js.map +1 -1
- package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.types.d.ts +2 -2
- package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
- package/lib-amd/types/IDataPoint.d.ts +4 -0
- package/lib-amd/types/IDataPoint.js.map +1 -1
- package/lib-amd/utilities/image-export-utils.js +18 -1
- package/lib-amd/utilities/image-export-utils.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +9 -2
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +4 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +218 -86
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.base.d.ts +2 -0
- package/lib-commonjs/components/LineChart/LineChart.base.js +58 -17
- package/lib-commonjs/components/LineChart/LineChart.base.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.types.d.ts +1 -1
- package/lib-commonjs/components/LineChart/LineChart.types.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.d.ts +2 -2
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
- package/lib-commonjs/types/IDataPoint.d.ts +4 -0
- package/lib-commonjs/types/IDataPoint.js.map +1 -1
- package/lib-commonjs/utilities/image-export-utils.js +18 -1
- package/lib-commonjs/utilities/image-export-utils.js.map +1 -1
- package/package.json +2 -2
- package/src/components/LineChart/LineChart.types.ts +1 -1
- package/src/components/VerticalStackedBarChart/VerticalStackedBarChart.types.ts +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
define(["require", "exports", "tslib", "d3-array", "d3-scale", "../../utilities/colors", "../GaugeChart/index", "../../utilities/utilities", "@fluentui/chart-utilities", "d3-time-format", "d3-shape", "./PlotlyColorAdapter"], function (require, exports, tslib_1, d3_array_1, d3_scale_1, colors_1, index_1, utilities_1, chart_utilities_1, d3_time_format_1, d3_shape_1, PlotlyColorAdapter_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
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
|
+
exports.getValidXYRanges = exports.getNumberAtIndexOrDefault = exports.isInvalidValue = 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;
|
|
5
5
|
var dashOptions = {
|
|
6
6
|
dot: {
|
|
7
7
|
strokeDasharray: '1, 5',
|
|
@@ -47,7 +47,8 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "../../utilities/
|
|
|
47
47
|
return parseFullMonth(possiblyMonthValue) !== null || parseShortMonth(possiblyMonthValue) !== null;
|
|
48
48
|
};
|
|
49
49
|
var isMonthArray = function (data) {
|
|
50
|
-
|
|
50
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
51
|
+
return (0, chart_utilities_1.isArrayOfType)(data, function (value) { return isMonth(value) || value === null; });
|
|
51
52
|
};
|
|
52
53
|
exports.isMonthArray = isMonthArray;
|
|
53
54
|
function getTitles(layout) {
|
|
@@ -69,19 +70,29 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "../../utilities/
|
|
|
69
70
|
var parsedDate = "".concat(possiblyMonthValue, " 01, ").concat(presentYear);
|
|
70
71
|
return (0, chart_utilities_1.isDate)(parsedDate) ? new Date(parsedDate) : null;
|
|
71
72
|
});
|
|
72
|
-
|
|
73
|
-
var
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
var filteredDateIndexPairs = dates.map(function (date, index) { return [date, index]; }).filter(function (_a) {
|
|
74
|
+
var date = _a[0];
|
|
75
|
+
return date !== null;
|
|
76
|
+
});
|
|
77
|
+
for (var i = filteredDateIndexPairs.length - 1; i > 0; i--) {
|
|
78
|
+
var currentDate = filteredDateIndexPairs[i][0];
|
|
79
|
+
var previousDate = filteredDateIndexPairs[i - 1][0];
|
|
80
|
+
var currentMonth = currentDate.getMonth();
|
|
81
|
+
var previousMonth = previousDate.getMonth();
|
|
82
|
+
var currentYear = currentDate.getFullYear();
|
|
83
|
+
var previousYear = previousDate.getFullYear();
|
|
77
84
|
if (previousMonth >= currentMonth) {
|
|
78
|
-
|
|
85
|
+
filteredDateIndexPairs[i - 1][0].setFullYear(currentYear - 1);
|
|
79
86
|
}
|
|
80
87
|
else if (previousYear > currentYear) {
|
|
81
|
-
|
|
88
|
+
filteredDateIndexPairs[i - 1][0].setFullYear(currentYear);
|
|
82
89
|
}
|
|
90
|
+
dates[filteredDateIndexPairs[i - 1][1]] = filteredDateIndexPairs[i - 1][0];
|
|
83
91
|
}
|
|
84
92
|
xValues = xValues.map(function (month, index) {
|
|
93
|
+
if (dates[index] === null) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
85
96
|
return "".concat(month, " 01, ").concat(dates[index].getFullYear());
|
|
86
97
|
});
|
|
87
98
|
return xValues;
|
|
@@ -142,20 +153,22 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "../../utilities/
|
|
|
142
153
|
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);
|
|
143
154
|
var mapLegendToDataPoint = {};
|
|
144
155
|
(_e = firstData.labels) === null || _e === void 0 ? void 0 : _e.forEach(function (label, index) {
|
|
145
|
-
var
|
|
156
|
+
var value = (0, exports.getNumberAtIndexOrDefault)(firstData.values, index);
|
|
157
|
+
if ((0, exports.isInvalidValue)(value) || value < 0) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
var legend = "".concat(label);
|
|
146
161
|
// resolve color for each legend from the extracted colors
|
|
147
|
-
var color = (0, PlotlyColorAdapter_1.resolveColor)(colors, index,
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
mapLegendToDataPoint[label] = {
|
|
152
|
-
legend: label,
|
|
162
|
+
var color = (0, PlotlyColorAdapter_1.resolveColor)(colors, index, legend, colorMap, isDarkTheme);
|
|
163
|
+
if (!mapLegendToDataPoint[legend]) {
|
|
164
|
+
mapLegendToDataPoint[legend] = {
|
|
165
|
+
legend: legend,
|
|
153
166
|
data: value,
|
|
154
167
|
color: color,
|
|
155
168
|
};
|
|
156
169
|
}
|
|
157
170
|
else {
|
|
158
|
-
mapLegendToDataPoint[
|
|
171
|
+
mapLegendToDataPoint[legend].data += value;
|
|
159
172
|
}
|
|
160
173
|
});
|
|
161
174
|
var width = (_g = (_f = input.layout) === null || _f === void 0 ? void 0 : _f.width) !== null && _g !== void 0 ? _g : 440;
|
|
@@ -188,46 +201,65 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "../../utilities/
|
|
|
188
201
|
var _a, _b, _c;
|
|
189
202
|
var mapXToDataPoints = {};
|
|
190
203
|
var yMaxValue = 0;
|
|
204
|
+
var yMinValue = 0;
|
|
191
205
|
var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
|
|
192
206
|
var _d = getLegendProps(input.data, input.layout), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
193
207
|
input.data.forEach(function (series, index1) {
|
|
194
|
-
var _a, _b, _c, _d, _e, _f, _g, _h
|
|
208
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
195
209
|
var isXYearCategory = (0, chart_utilities_1.isYearArray)(series.x); // Consider year as categorical not numeric continuous axis
|
|
196
210
|
// extract bar colors for each series only once
|
|
197
211
|
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);
|
|
198
212
|
// extract line colors for each series only once
|
|
199
213
|
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);
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
var dashType = ((_c = series.line) === null || _c === void 0 ? void 0 : _c.dash) || 'solid';
|
|
221
|
-
var legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot' ? 'dottedLine' : 'default';
|
|
222
|
-
mapXToDataPoints[x].lineData.push(tslib_1.__assign(tslib_1.__assign({ legend: legend, legendShape: legendShape, y: yVal, color: lineColor }, (lineOptions ? { lineOptions: lineOptions } : {})), { useSecondaryYScale: usesSecondaryYScale(series) }));
|
|
223
|
-
if (!usesSecondaryYScale(series)) {
|
|
214
|
+
var validXYRanges = (0, exports.getValidXYRanges)(series);
|
|
215
|
+
validXYRanges.forEach(function (_a, rangeIdx) {
|
|
216
|
+
var rangeStart = _a[0], rangeEnd = _a[1];
|
|
217
|
+
var rangeXValues = series.x.slice(rangeStart, rangeEnd);
|
|
218
|
+
var rangeYValues = series.y.slice(rangeStart, rangeEnd);
|
|
219
|
+
rangeXValues.forEach(function (x, index2) {
|
|
220
|
+
var _a, _b;
|
|
221
|
+
if (!mapXToDataPoints[x]) {
|
|
222
|
+
mapXToDataPoints[x] = { xAxisPoint: isXYearCategory ? x.toString() : x, chartData: [], lineData: [] };
|
|
223
|
+
}
|
|
224
|
+
var legend = legends[index1];
|
|
225
|
+
// resolve color for each legend's bars from the extracted colors
|
|
226
|
+
var color = (0, PlotlyColorAdapter_1.resolveColor)(extractedBarColors, index1, legend, colorMap, isDarkTheme);
|
|
227
|
+
var yVal = rangeYValues[index2];
|
|
228
|
+
if (series.type === 'bar') {
|
|
229
|
+
mapXToDataPoints[x].chartData.push({
|
|
230
|
+
legend: legend,
|
|
231
|
+
data: yVal,
|
|
232
|
+
color: color,
|
|
233
|
+
});
|
|
224
234
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
225
235
|
}
|
|
226
|
-
|
|
236
|
+
else if (series.type === 'scatter' || !!fallbackVSBC) {
|
|
237
|
+
var lineColor = (0, PlotlyColorAdapter_1.resolveColor)(extractedLineColors, index1, legend, colorMap, isDarkTheme);
|
|
238
|
+
var lineOptions = getLineOptions(series.line);
|
|
239
|
+
var dashType = ((_a = series.line) === null || _a === void 0 ? void 0 : _a.dash) || 'solid';
|
|
240
|
+
var legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot'
|
|
241
|
+
? 'dottedLine'
|
|
242
|
+
: ((_b = series.mode) === null || _b === void 0 ? void 0 : _b.includes('markers'))
|
|
243
|
+
? 'circle'
|
|
244
|
+
: 'default';
|
|
245
|
+
mapXToDataPoints[x].lineData.push({
|
|
246
|
+
legend: legend + (validXYRanges.length > 1 ? ".".concat(rangeIdx + 1) : ''),
|
|
247
|
+
legendShape: legendShape,
|
|
248
|
+
y: yVal,
|
|
249
|
+
color: lineColor,
|
|
250
|
+
lineOptions: tslib_1.__assign(tslib_1.__assign({}, (lineOptions !== null && lineOptions !== void 0 ? lineOptions : {})), { mode: series.mode }),
|
|
251
|
+
useSecondaryYScale: usesSecondaryYScale(series),
|
|
252
|
+
});
|
|
253
|
+
if (!usesSecondaryYScale(series)) {
|
|
254
|
+
yMaxValue = Math.max(yMaxValue, yVal);
|
|
255
|
+
yMinValue = Math.min(yMinValue, yVal);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
});
|
|
227
259
|
});
|
|
228
260
|
});
|
|
229
261
|
var _e = getTitles(input.layout), chartTitle = _e.chartTitle, xAxisTitle = _e.xAxisTitle, yAxisTitle = _e.yAxisTitle;
|
|
230
|
-
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 });
|
|
262
|
+
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, yMinValue: yMinValue, chartTitle: chartTitle, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle, mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true, supportNegativeData: true, barGapMax: 2 });
|
|
231
263
|
};
|
|
232
264
|
exports.transformPlotlyJsonToVSBCProps = transformPlotlyJsonToVSBCProps;
|
|
233
265
|
var transformPlotlyJsonToGVBCProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -240,7 +272,10 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "../../utilities/
|
|
|
240
272
|
// extract colors for each series only once
|
|
241
273
|
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);
|
|
242
274
|
(_e = series.x) === null || _e === void 0 ? void 0 : _e.forEach(function (x, xIndex) {
|
|
243
|
-
var _a
|
|
275
|
+
var _a;
|
|
276
|
+
if ((0, exports.isInvalidValue)(x) || (0, exports.isInvalidValue)((_a = series.y) === null || _a === void 0 ? void 0 : _a[xIndex])) {
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
244
279
|
if (!mapXToDataPoints[x]) {
|
|
245
280
|
mapXToDataPoints[x] = { name: x.toString(), series: [] };
|
|
246
281
|
}
|
|
@@ -250,7 +285,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "../../utilities/
|
|
|
250
285
|
var color = (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, index1, legend, colorMap, isDarkTheme);
|
|
251
286
|
mapXToDataPoints[x].series.push({
|
|
252
287
|
key: legend,
|
|
253
|
-
data:
|
|
288
|
+
data: series.y[xIndex],
|
|
254
289
|
xAxisCalloutData: x,
|
|
255
290
|
color: color,
|
|
256
291
|
legend: legend,
|
|
@@ -274,17 +309,26 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "../../utilities/
|
|
|
274
309
|
}
|
|
275
310
|
// extract colors for each series only once
|
|
276
311
|
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);
|
|
277
|
-
var
|
|
312
|
+
var xValues = [];
|
|
313
|
+
var yValues = [];
|
|
314
|
+
series.x.forEach(function (xVal, index) {
|
|
315
|
+
var yVal = (0, exports.getNumberAtIndexOrDefault)(series.y, index);
|
|
316
|
+
if ((0, exports.isInvalidValue)(xVal) || (0, exports.isInvalidValue)(yVal)) {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
xValues.push(xVal);
|
|
320
|
+
yValues.push(yVal);
|
|
321
|
+
});
|
|
322
|
+
var isXString = isStringArray(xValues);
|
|
278
323
|
// TODO: In case of a single bin, add an empty bin of the same size to prevent the
|
|
279
324
|
// default bar width from being used and ensure the bar spans the full intended range.
|
|
280
|
-
var xBins = createBins(
|
|
325
|
+
var xBins = createBins(xValues, (_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);
|
|
281
326
|
var yBins = xBins.map(function () { return []; });
|
|
282
327
|
var total = 0;
|
|
283
|
-
|
|
284
|
-
var _a, _b;
|
|
328
|
+
xValues.forEach(function (xVal, index) {
|
|
285
329
|
var binIdx = findBinIndex(xBins, xVal, isXString);
|
|
286
330
|
if (binIdx !== -1) {
|
|
287
|
-
yBins[binIdx].push(
|
|
331
|
+
yBins[binIdx].push(yValues[index]);
|
|
288
332
|
}
|
|
289
333
|
});
|
|
290
334
|
var y = yBins.map(function (bin) {
|
|
@@ -324,12 +368,13 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "../../utilities/
|
|
|
324
368
|
var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
|
|
325
369
|
var mode = 'tonexty';
|
|
326
370
|
var _g = getLegendProps(input.data, input.layout), legends = _g.legends, hideLegend = _g.hideLegend;
|
|
327
|
-
var chartData = input.data
|
|
328
|
-
|
|
371
|
+
var chartData = input.data
|
|
372
|
+
.map(function (series, index) {
|
|
373
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
329
374
|
// extract colors for each series only once
|
|
330
375
|
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);
|
|
331
376
|
var xValues = series.x;
|
|
332
|
-
var isString =
|
|
377
|
+
var isString = isStringArray(xValues);
|
|
333
378
|
var isXDate = (0, chart_utilities_1.isDateArray)(xValues);
|
|
334
379
|
var isXNumber = (0, chart_utilities_1.isNumberArray)(xValues);
|
|
335
380
|
var legend = legends[index];
|
|
@@ -338,27 +383,50 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "../../utilities/
|
|
|
338
383
|
mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
|
|
339
384
|
var lineOptions = getLineOptions(series.line);
|
|
340
385
|
var dashType = ((_f = series.line) === null || _f === void 0 ? void 0 : _f.dash) || 'solid';
|
|
341
|
-
var legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot'
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
386
|
+
var legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot'
|
|
387
|
+
? 'dottedLine'
|
|
388
|
+
: ((_g = series.mode) === null || _g === void 0 ? void 0 : _g.includes('markers'))
|
|
389
|
+
? 'circle'
|
|
390
|
+
: 'default';
|
|
391
|
+
var validXYRanges = (0, exports.getValidXYRanges)(series);
|
|
392
|
+
return validXYRanges.map(function (_a, rangeIdx) {
|
|
393
|
+
var _b;
|
|
394
|
+
var rangeStart = _a[0], rangeEnd = _a[1];
|
|
395
|
+
var rangeXValues = xValues.slice(rangeStart, rangeEnd);
|
|
396
|
+
var rangeYValues = series.y.slice(rangeStart, rangeEnd);
|
|
397
|
+
var markerSizes = (0, chart_utilities_1.isArrayOrTypedArray)((_b = series.marker) === null || _b === void 0 ? void 0 : _b.size)
|
|
398
|
+
? series.marker.size.slice(rangeStart, rangeEnd)
|
|
399
|
+
: [];
|
|
400
|
+
return {
|
|
401
|
+
legend: legend,
|
|
402
|
+
legendShape: legendShape,
|
|
403
|
+
data: rangeXValues.map(function (x, i) {
|
|
404
|
+
var _a, _b;
|
|
405
|
+
return (tslib_1.__assign({ x: isString ? (isXDate ? new Date(x) : isXNumber ? parseFloat(x) : x) : x, y: rangeYValues[i] }, (Array.isArray((_a = series.marker) === null || _a === void 0 ? void 0 : _a.size)
|
|
406
|
+
? { markerSize: markerSizes[i] }
|
|
407
|
+
: typeof ((_b = series.marker) === null || _b === void 0 ? void 0 : _b.size) === 'number'
|
|
408
|
+
? { markerSize: series.marker.size }
|
|
409
|
+
: {})));
|
|
410
|
+
}),
|
|
411
|
+
color: seriesColor,
|
|
412
|
+
lineOptions: tslib_1.__assign(tslib_1.__assign({}, (lineOptions !== null && lineOptions !== void 0 ? lineOptions : {})), { mode: series.mode }),
|
|
413
|
+
useSecondaryYScale: usesSecondaryYScale(series),
|
|
414
|
+
};
|
|
415
|
+
});
|
|
416
|
+
})
|
|
417
|
+
.flat();
|
|
351
418
|
var yMinMaxValues = (0, utilities_1.findNumericMinMaxOfY)(chartData);
|
|
352
419
|
var _h = getTitles(input.layout), chartTitle = _h.chartTitle, xAxisTitle = _h.xAxisTitle, yAxisTitle = _h.yAxisTitle;
|
|
420
|
+
var numDataPoints = chartData.reduce(function (total, lineChartPoints) { return total + lineChartPoints.data.length; }, 0);
|
|
353
421
|
var chartProps = {
|
|
354
422
|
chartTitle: chartTitle,
|
|
355
423
|
lineChartData: chartData,
|
|
356
424
|
};
|
|
357
425
|
if (isAreaChart) {
|
|
358
|
-
return tslib_1.__assign(tslib_1.__assign({ data: chartProps, supportNegativeData: true, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle }, secondaryYAxisValues), { mode: mode, 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, hideTickOverlap: true, hideLegend: hideLegend, useUTC: false });
|
|
426
|
+
return tslib_1.__assign(tslib_1.__assign({ data: chartProps, supportNegativeData: true, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle }, secondaryYAxisValues), { mode: mode, 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, hideTickOverlap: true, hideLegend: hideLegend, useUTC: false, optimizeLargeData: numDataPoints > 1000 });
|
|
359
427
|
}
|
|
360
428
|
else {
|
|
361
|
-
return tslib_1.__assign(tslib_1.__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 });
|
|
429
|
+
return tslib_1.__assign(tslib_1.__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, optimizeLargeData: numDataPoints > 1000 });
|
|
362
430
|
}
|
|
363
431
|
};
|
|
364
432
|
exports.transformPlotlyJsonToScatterChartProps = transformPlotlyJsonToScatterChartProps;
|
|
@@ -373,14 +441,20 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "../../utilities/
|
|
|
373
441
|
var legend = legends[index];
|
|
374
442
|
// resolve color for each legend's bars from the extracted colors
|
|
375
443
|
var color = (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
376
|
-
return series.y
|
|
444
|
+
return series.y
|
|
445
|
+
.map(function (yValue, i) {
|
|
446
|
+
var _a;
|
|
447
|
+
if ((0, exports.isInvalidValue)((_a = series.x) === null || _a === void 0 ? void 0 : _a[i]) || (0, exports.isInvalidValue)(yValue)) {
|
|
448
|
+
return null;
|
|
449
|
+
}
|
|
377
450
|
return {
|
|
378
451
|
x: series.x[i],
|
|
379
452
|
y: yValue,
|
|
380
453
|
legend: legend,
|
|
381
454
|
color: color,
|
|
382
455
|
};
|
|
383
|
-
})
|
|
456
|
+
})
|
|
457
|
+
.filter(function (point) { return point !== null; });
|
|
384
458
|
})
|
|
385
459
|
.reverse()
|
|
386
460
|
.flat()
|
|
@@ -425,18 +499,30 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "../../utilities/
|
|
|
425
499
|
var zMin = Number.POSITIVE_INFINITY;
|
|
426
500
|
var zMax = Number.NEGATIVE_INFINITY;
|
|
427
501
|
if (firstData.type === 'histogram2d') {
|
|
428
|
-
var
|
|
429
|
-
var
|
|
430
|
-
var
|
|
431
|
-
|
|
502
|
+
var xValues_1 = [];
|
|
503
|
+
var yValues_1 = [];
|
|
504
|
+
var zValues_1 = [];
|
|
505
|
+
(_a = firstData.x) === null || _a === void 0 ? void 0 : _a.forEach(function (xVal, index) {
|
|
506
|
+
var _a;
|
|
507
|
+
var zVal = (0, exports.getNumberAtIndexOrDefault)(firstData.z, index);
|
|
508
|
+
if ((0, exports.isInvalidValue)(xVal) || (0, exports.isInvalidValue)((_a = firstData.y) === null || _a === void 0 ? void 0 : _a[index]) || (0, exports.isInvalidValue)(zVal)) {
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
xValues_1.push(xVal);
|
|
512
|
+
yValues_1.push(firstData.y[index]);
|
|
513
|
+
zValues_1.push(zVal);
|
|
514
|
+
});
|
|
515
|
+
var isXString_1 = isStringArray(xValues_1);
|
|
516
|
+
var isYString_1 = isStringArray(yValues_1);
|
|
517
|
+
var xBins_1 = createBins(xValues_1, (_b = firstData.xbins) === null || _b === void 0 ? void 0 : _b.start, (_c = firstData.xbins) === null || _c === void 0 ? void 0 : _c.end, (_d = firstData.xbins) === null || _d === void 0 ? void 0 : _d.size);
|
|
518
|
+
var yBins_1 = createBins(yValues_1, (_e = firstData.ybins) === null || _e === void 0 ? void 0 : _e.start, (_f = firstData.ybins) === null || _f === void 0 ? void 0 : _f.end, (_g = firstData.ybins) === null || _g === void 0 ? void 0 : _g.size);
|
|
432
519
|
var zBins_1 = yBins_1.map(function () { return xBins_1.map(function () { return []; }); });
|
|
433
520
|
var total_1 = 0;
|
|
434
|
-
|
|
435
|
-
var _a, _b, _c;
|
|
521
|
+
xValues_1.forEach(function (xVal, index) {
|
|
436
522
|
var xBinIdx = findBinIndex(xBins_1, xVal, isXString_1);
|
|
437
|
-
var yBinIdx = findBinIndex(yBins_1,
|
|
523
|
+
var yBinIdx = findBinIndex(yBins_1, yValues_1[index], isYString_1);
|
|
438
524
|
if (xBinIdx !== -1 && yBinIdx !== -1) {
|
|
439
|
-
zBins_1[yBinIdx][xBinIdx].push(
|
|
525
|
+
zBins_1[yBinIdx][xBinIdx].push(zValues_1[index]);
|
|
440
526
|
}
|
|
441
527
|
});
|
|
442
528
|
var z_1 = zBins_1.map(function (row) {
|
|
@@ -523,13 +609,19 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "../../utilities/
|
|
|
523
609
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
524
610
|
var _m = input.data[0], link = _m.link, node = _m.node;
|
|
525
611
|
var validLinks = ((_a = link === null || link === void 0 ? void 0 : link.value) !== null && _a !== void 0 ? _a : [])
|
|
526
|
-
.map(function (val, index) {
|
|
527
|
-
|
|
528
|
-
source: link === null || link === void 0 ? void 0 : link.
|
|
529
|
-
|
|
530
|
-
|
|
612
|
+
.map(function (val, index) {
|
|
613
|
+
var _a, _b;
|
|
614
|
+
if ((0, exports.isInvalidValue)(val) || (0, exports.isInvalidValue)((_a = link === null || link === void 0 ? void 0 : link.source) === null || _a === void 0 ? void 0 : _a[index]) || (0, exports.isInvalidValue)((_b = link === null || link === void 0 ? void 0 : link.target) === null || _b === void 0 ? void 0 : _b[index])) {
|
|
615
|
+
return null;
|
|
616
|
+
}
|
|
617
|
+
return {
|
|
618
|
+
value: val,
|
|
619
|
+
source: link === null || link === void 0 ? void 0 : link.source[index],
|
|
620
|
+
target: link === null || link === void 0 ? void 0 : link.target[index],
|
|
621
|
+
};
|
|
622
|
+
})
|
|
531
623
|
// Filter out negative nodes, unequal nodes and self-references (circular links)
|
|
532
|
-
.filter(function (x) { return x.source >= 0 && x.target >= 0 && x.source !== x.target; });
|
|
624
|
+
.filter(function (x) { return x !== null && x.source >= 0 && x.target >= 0 && x.source !== x.target; });
|
|
533
625
|
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);
|
|
534
626
|
var sankeyChartData = {
|
|
535
627
|
nodes: (_e = node.label) === null || _e === void 0 ? void 0 : _e.map(function (label, index) {
|
|
@@ -674,16 +766,20 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "../../utilities/
|
|
|
674
766
|
};
|
|
675
767
|
exports.transformPlotlyJsonToChartTableProps = transformPlotlyJsonToChartTableProps;
|
|
676
768
|
var projectPolarToCartesian = function (input) {
|
|
769
|
+
var _a, _b, _c, _d;
|
|
677
770
|
var projection = tslib_1.__assign({}, input);
|
|
678
771
|
for (var sindex = 0; sindex < input.data.length; sindex++) {
|
|
679
772
|
var series = input.data[sindex];
|
|
680
773
|
series.x = [];
|
|
681
774
|
series.y = [];
|
|
682
|
-
for (var ptindex = 0; ptindex < series.r.length; ptindex++) {
|
|
775
|
+
for (var ptindex = 0; ptindex < ((_b = (_a = series.r) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0); ptindex++) {
|
|
776
|
+
if ((0, exports.isInvalidValue)((_c = series.theta) === null || _c === void 0 ? void 0 : _c[ptindex]) || (0, exports.isInvalidValue)((_d = series.r) === null || _d === void 0 ? void 0 : _d[ptindex])) {
|
|
777
|
+
continue;
|
|
778
|
+
}
|
|
683
779
|
var thetaRad = (series.theta[ptindex] * Math.PI) / 180;
|
|
684
780
|
var radius = series.r[ptindex];
|
|
685
|
-
series.x
|
|
686
|
-
series.y
|
|
781
|
+
series.x.push(radius * Math.cos(thetaRad));
|
|
782
|
+
series.y.push(radius * Math.sin(thetaRad));
|
|
687
783
|
}
|
|
688
784
|
projection.data[sindex] = series;
|
|
689
785
|
}
|
|
@@ -771,7 +867,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "../../utilities/
|
|
|
771
867
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
772
868
|
var isStringArray = function (arr) {
|
|
773
869
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
774
|
-
return (0, chart_utilities_1.isArrayOfType)(arr, function (value) { return typeof value === 'string'; });
|
|
870
|
+
return (0, chart_utilities_1.isArrayOfType)(arr, function (value) { return typeof value === 'string' || value === null; });
|
|
775
871
|
};
|
|
776
872
|
// TODO: Use binary search to find the appropriate bin for numeric value.
|
|
777
873
|
var findBinIndex = function (bins, value, isString) {
|
|
@@ -883,5 +979,41 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "../../utilities/
|
|
|
883
979
|
hideLegend: (layout === null || layout === void 0 ? void 0 : layout.showlegend) === false || ((layout === null || layout === void 0 ? void 0 : layout.showlegend) !== true && legends.length < 2) ? true : hideLegends,
|
|
884
980
|
};
|
|
885
981
|
};
|
|
982
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
983
|
+
var isInvalidValue = function (value) {
|
|
984
|
+
return typeof value === 'undefined' || value === null || (typeof value === 'number' && !isFinite(value));
|
|
985
|
+
};
|
|
986
|
+
exports.isInvalidValue = isInvalidValue;
|
|
987
|
+
var getNumberAtIndexOrDefault = function (data, index) {
|
|
988
|
+
if ((0, chart_utilities_1.isArrayOrTypedArray)(data)) {
|
|
989
|
+
if (typeof data[index] !== 'number' || !isFinite(data[index])) {
|
|
990
|
+
return;
|
|
991
|
+
}
|
|
992
|
+
return data[index];
|
|
993
|
+
}
|
|
994
|
+
return 1;
|
|
995
|
+
};
|
|
996
|
+
exports.getNumberAtIndexOrDefault = getNumberAtIndexOrDefault;
|
|
997
|
+
var getValidXYRanges = function (series) {
|
|
998
|
+
if (!(0, chart_utilities_1.isArrayOrTypedArray)(series.x) || !(0, chart_utilities_1.isArrayOrTypedArray)(series.y)) {
|
|
999
|
+
return [];
|
|
1000
|
+
}
|
|
1001
|
+
var ranges = [];
|
|
1002
|
+
var start = 0;
|
|
1003
|
+
var end = 0;
|
|
1004
|
+
for (; end < series.x.length; end++) {
|
|
1005
|
+
if ((0, exports.isInvalidValue)(series.x[end]) || (0, exports.isInvalidValue)(series.y[end])) {
|
|
1006
|
+
if (end - start > 0) {
|
|
1007
|
+
ranges.push([start, end]);
|
|
1008
|
+
}
|
|
1009
|
+
start = end + 1;
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
if (end - start > 0) {
|
|
1013
|
+
ranges.push([start, end]);
|
|
1014
|
+
}
|
|
1015
|
+
return ranges;
|
|
1016
|
+
};
|
|
1017
|
+
exports.getValidXYRanges = getValidXYRanges;
|
|
886
1018
|
});
|
|
887
1019
|
//# sourceMappingURL=PlotlySchemaAdapter.js.map
|