@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.
Files changed (57) hide show
  1. package/CHANGELOG.json +55 -1
  2. package/CHANGELOG.md +24 -2
  3. package/dist/react-charting.d.ts +7 -3
  4. package/dist/react-charting.js +1 -1
  5. package/dist/react-charting.min.js +1 -1
  6. package/etc/react-charting.api.md +3 -1
  7. package/lib/components/DeclarativeChart/DeclarativeChart.js +9 -2
  8. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  9. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +4 -1
  10. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +214 -85
  11. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  12. package/lib/components/LineChart/LineChart.base.d.ts +2 -0
  13. package/lib/components/LineChart/LineChart.base.js +58 -17
  14. package/lib/components/LineChart/LineChart.base.js.map +1 -1
  15. package/lib/components/LineChart/LineChart.types.d.ts +1 -1
  16. package/lib/components/LineChart/LineChart.types.js.map +1 -1
  17. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.d.ts +2 -2
  18. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
  19. package/lib/types/IDataPoint.d.ts +4 -0
  20. package/lib/types/IDataPoint.js.map +1 -1
  21. package/lib/utilities/image-export-utils.js +18 -1
  22. package/lib/utilities/image-export-utils.js.map +1 -1
  23. package/lib-amd/components/DeclarativeChart/DeclarativeChart.js +9 -2
  24. package/lib-amd/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  25. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +4 -1
  26. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +218 -86
  27. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  28. package/lib-amd/components/LineChart/LineChart.base.d.ts +2 -0
  29. package/lib-amd/components/LineChart/LineChart.base.js +58 -17
  30. package/lib-amd/components/LineChart/LineChart.base.js.map +1 -1
  31. package/lib-amd/components/LineChart/LineChart.types.d.ts +1 -1
  32. package/lib-amd/components/LineChart/LineChart.types.js.map +1 -1
  33. package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.types.d.ts +2 -2
  34. package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
  35. package/lib-amd/types/IDataPoint.d.ts +4 -0
  36. package/lib-amd/types/IDataPoint.js.map +1 -1
  37. package/lib-amd/utilities/image-export-utils.js +18 -1
  38. package/lib-amd/utilities/image-export-utils.js.map +1 -1
  39. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +9 -2
  40. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  41. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +4 -1
  42. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +218 -86
  43. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  44. package/lib-commonjs/components/LineChart/LineChart.base.d.ts +2 -0
  45. package/lib-commonjs/components/LineChart/LineChart.base.js +58 -17
  46. package/lib-commonjs/components/LineChart/LineChart.base.js.map +1 -1
  47. package/lib-commonjs/components/LineChart/LineChart.types.d.ts +1 -1
  48. package/lib-commonjs/components/LineChart/LineChart.types.js.map +1 -1
  49. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.d.ts +2 -2
  50. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
  51. package/lib-commonjs/types/IDataPoint.d.ts +4 -0
  52. package/lib-commonjs/types/IDataPoint.js.map +1 -1
  53. package/lib-commonjs/utilities/image-export-utils.js +18 -1
  54. package/lib-commonjs/utilities/image-export-utils.js.map +1 -1
  55. package/package.json +2 -2
  56. package/src/components/LineChart/LineChart.types.ts +1 -1
  57. package/src/components/VerticalStackedBarChart/VerticalStackedBarChart.types.ts +2 -2
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
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;
3
+ 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;
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");
@@ -56,7 +56,8 @@ var isMonth = function (possiblyMonthValue) {
56
56
  return parseFullMonth(possiblyMonthValue) !== null || parseShortMonth(possiblyMonthValue) !== null;
57
57
  };
58
58
  var isMonthArray = function (data) {
59
- return (0, chart_utilities_1.isArrayOfType)(data, isMonth);
59
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
60
+ return (0, chart_utilities_1.isArrayOfType)(data, function (value) { return isMonth(value) || value === null; });
60
61
  };
61
62
  exports.isMonthArray = isMonthArray;
62
63
  function getTitles(layout) {
@@ -78,19 +79,29 @@ var correctYearMonth = function (xValues) {
78
79
  var parsedDate = "".concat(possiblyMonthValue, " 01, ").concat(presentYear);
79
80
  return (0, chart_utilities_1.isDate)(parsedDate) ? new Date(parsedDate) : null;
80
81
  });
81
- for (var i = dates.length - 1; i > 0; i--) {
82
- var currentMonth = dates[i].getMonth();
83
- var previousMonth = dates[i - 1].getMonth();
84
- var currentYear = dates[i].getFullYear();
85
- var previousYear = dates[i - 1].getFullYear();
82
+ var filteredDateIndexPairs = dates.map(function (date, index) { return [date, index]; }).filter(function (_a) {
83
+ var date = _a[0];
84
+ return date !== null;
85
+ });
86
+ for (var i = filteredDateIndexPairs.length - 1; i > 0; i--) {
87
+ var currentDate = filteredDateIndexPairs[i][0];
88
+ var previousDate = filteredDateIndexPairs[i - 1][0];
89
+ var currentMonth = currentDate.getMonth();
90
+ var previousMonth = previousDate.getMonth();
91
+ var currentYear = currentDate.getFullYear();
92
+ var previousYear = previousDate.getFullYear();
86
93
  if (previousMonth >= currentMonth) {
87
- dates[i - 1].setFullYear(dates[i].getFullYear() - 1);
94
+ filteredDateIndexPairs[i - 1][0].setFullYear(currentYear - 1);
88
95
  }
89
96
  else if (previousYear > currentYear) {
90
- dates[i - 1].setFullYear(currentYear);
97
+ filteredDateIndexPairs[i - 1][0].setFullYear(currentYear);
91
98
  }
99
+ dates[filteredDateIndexPairs[i - 1][1]] = filteredDateIndexPairs[i - 1][0];
92
100
  }
93
101
  xValues = xValues.map(function (month, index) {
102
+ if (dates[index] === null) {
103
+ return null;
104
+ }
94
105
  return "".concat(month, " 01, ").concat(dates[index].getFullYear());
95
106
  });
96
107
  return xValues;
@@ -151,20 +162,22 @@ var transformPlotlyJsonToDonutProps = function (input, colorMap, colorwayType, i
151
162
  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);
152
163
  var mapLegendToDataPoint = {};
153
164
  (_e = firstData.labels) === null || _e === void 0 ? void 0 : _e.forEach(function (label, index) {
154
- var _a;
165
+ var value = (0, exports.getNumberAtIndexOrDefault)(firstData.values, index);
166
+ if ((0, exports.isInvalidValue)(value) || value < 0) {
167
+ return;
168
+ }
169
+ var legend = "".concat(label);
155
170
  // resolve color for each legend from the extracted colors
156
- var color = (0, PlotlyColorAdapter_1.resolveColor)(colors, index, label, colorMap, isDarkTheme);
157
- //ToDo how to handle string data?
158
- var value = typeof ((_a = firstData.values) === null || _a === void 0 ? void 0 : _a[index]) === 'number' ? firstData.values[index] : 1;
159
- if (!mapLegendToDataPoint[label]) {
160
- mapLegendToDataPoint[label] = {
161
- legend: label,
171
+ var color = (0, PlotlyColorAdapter_1.resolveColor)(colors, index, legend, colorMap, isDarkTheme);
172
+ if (!mapLegendToDataPoint[legend]) {
173
+ mapLegendToDataPoint[legend] = {
174
+ legend: legend,
162
175
  data: value,
163
176
  color: color,
164
177
  };
165
178
  }
166
179
  else {
167
- mapLegendToDataPoint[label].data += value;
180
+ mapLegendToDataPoint[legend].data += value;
168
181
  }
169
182
  });
170
183
  var width = (_g = (_f = input.layout) === null || _f === void 0 ? void 0 : _f.width) !== null && _g !== void 0 ? _g : 440;
@@ -197,46 +210,65 @@ var transformPlotlyJsonToVSBCProps = function (input, colorMap, colorwayType, is
197
210
  var _a, _b, _c;
198
211
  var mapXToDataPoints = {};
199
212
  var yMaxValue = 0;
213
+ var yMinValue = 0;
200
214
  var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
201
215
  var _d = getLegendProps(input.data, input.layout), legends = _d.legends, hideLegend = _d.hideLegend;
202
216
  input.data.forEach(function (series, index1) {
203
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
217
+ var _a, _b, _c, _d, _e, _f, _g, _h;
204
218
  var isXYearCategory = (0, chart_utilities_1.isYearArray)(series.x); // Consider year as categorical not numeric continuous axis
205
219
  // extract bar colors for each series only once
206
220
  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);
207
221
  // extract line colors for each series only once
208
222
  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) {
210
- var _a, _b, _c;
211
- if (!mapXToDataPoints[x]) {
212
- mapXToDataPoints[x] = { xAxisPoint: isXYearCategory ? x.toString() : x, chartData: [], lineData: [] };
213
- }
214
- var legend = legends[index1];
215
- // resolve color for each legend's bars from the extracted colors
216
- var color = (0, PlotlyColorAdapter_1.resolveColor)(extractedBarColors, index1, legend, colorMap, isDarkTheme);
217
- var yVal = (_b = (_a = series.y) === null || _a === void 0 ? void 0 : _a[index2]) !== null && _b !== void 0 ? _b : 0;
218
- if (series.type === 'bar') {
219
- mapXToDataPoints[x].chartData.push({
220
- legend: legend,
221
- data: yVal,
222
- color: color,
223
- });
224
- yMaxValue = Math.max(yMaxValue, yVal);
225
- }
226
- else if (series.type === 'scatter' || !!fallbackVSBC) {
227
- var lineColor = (0, PlotlyColorAdapter_1.resolveColor)(extractedLineColors, index1, legend, colorMap, isDarkTheme);
228
- var lineOptions = getLineOptions(series.line);
229
- var dashType = ((_c = series.line) === null || _c === void 0 ? void 0 : _c.dash) || 'solid';
230
- var legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot' ? 'dottedLine' : 'default';
231
- mapXToDataPoints[x].lineData.push(tslib_1.__assign(tslib_1.__assign({ legend: legend, legendShape: legendShape, y: yVal, color: lineColor }, (lineOptions ? { lineOptions: lineOptions } : {})), { useSecondaryYScale: usesSecondaryYScale(series) }));
232
- if (!usesSecondaryYScale(series)) {
223
+ var validXYRanges = (0, exports.getValidXYRanges)(series);
224
+ validXYRanges.forEach(function (_a, rangeIdx) {
225
+ var rangeStart = _a[0], rangeEnd = _a[1];
226
+ var rangeXValues = series.x.slice(rangeStart, rangeEnd);
227
+ var rangeYValues = series.y.slice(rangeStart, rangeEnd);
228
+ rangeXValues.forEach(function (x, index2) {
229
+ var _a, _b;
230
+ if (!mapXToDataPoints[x]) {
231
+ mapXToDataPoints[x] = { xAxisPoint: isXYearCategory ? x.toString() : x, chartData: [], lineData: [] };
232
+ }
233
+ var legend = legends[index1];
234
+ // resolve color for each legend's bars from the extracted colors
235
+ var color = (0, PlotlyColorAdapter_1.resolveColor)(extractedBarColors, index1, legend, colorMap, isDarkTheme);
236
+ var yVal = rangeYValues[index2];
237
+ if (series.type === 'bar') {
238
+ mapXToDataPoints[x].chartData.push({
239
+ legend: legend,
240
+ data: yVal,
241
+ color: color,
242
+ });
233
243
  yMaxValue = Math.max(yMaxValue, yVal);
234
244
  }
235
- }
245
+ else if (series.type === 'scatter' || !!fallbackVSBC) {
246
+ var lineColor = (0, PlotlyColorAdapter_1.resolveColor)(extractedLineColors, index1, legend, colorMap, isDarkTheme);
247
+ var lineOptions = getLineOptions(series.line);
248
+ var dashType = ((_a = series.line) === null || _a === void 0 ? void 0 : _a.dash) || 'solid';
249
+ var legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot'
250
+ ? 'dottedLine'
251
+ : ((_b = series.mode) === null || _b === void 0 ? void 0 : _b.includes('markers'))
252
+ ? 'circle'
253
+ : 'default';
254
+ mapXToDataPoints[x].lineData.push({
255
+ legend: legend + (validXYRanges.length > 1 ? ".".concat(rangeIdx + 1) : ''),
256
+ legendShape: legendShape,
257
+ y: yVal,
258
+ color: lineColor,
259
+ lineOptions: tslib_1.__assign(tslib_1.__assign({}, (lineOptions !== null && lineOptions !== void 0 ? lineOptions : {})), { mode: series.mode }),
260
+ useSecondaryYScale: usesSecondaryYScale(series),
261
+ });
262
+ if (!usesSecondaryYScale(series)) {
263
+ yMaxValue = Math.max(yMaxValue, yVal);
264
+ yMinValue = Math.min(yMinValue, yVal);
265
+ }
266
+ }
267
+ });
236
268
  });
237
269
  });
238
270
  var _e = getTitles(input.layout), chartTitle = _e.chartTitle, xAxisTitle = _e.xAxisTitle, yAxisTitle = _e.yAxisTitle;
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 });
271
+ 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 });
240
272
  };
241
273
  exports.transformPlotlyJsonToVSBCProps = transformPlotlyJsonToVSBCProps;
242
274
  var transformPlotlyJsonToGVBCProps = function (input, colorMap, colorwayType, isDarkTheme) {
@@ -249,7 +281,10 @@ var transformPlotlyJsonToGVBCProps = function (input, colorMap, colorwayType, is
249
281
  // extract colors for each series only once
250
282
  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
283
  (_e = series.x) === null || _e === void 0 ? void 0 : _e.forEach(function (x, xIndex) {
252
- var _a, _b;
284
+ var _a;
285
+ if ((0, exports.isInvalidValue)(x) || (0, exports.isInvalidValue)((_a = series.y) === null || _a === void 0 ? void 0 : _a[xIndex])) {
286
+ return;
287
+ }
253
288
  if (!mapXToDataPoints[x]) {
254
289
  mapXToDataPoints[x] = { name: x.toString(), series: [] };
255
290
  }
@@ -259,7 +294,7 @@ var transformPlotlyJsonToGVBCProps = function (input, colorMap, colorwayType, is
259
294
  var color = (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, index1, legend, colorMap, isDarkTheme);
260
295
  mapXToDataPoints[x].series.push({
261
296
  key: legend,
262
- data: (_b = (_a = series.y) === null || _a === void 0 ? void 0 : _a[xIndex]) !== null && _b !== void 0 ? _b : 0,
297
+ data: series.y[xIndex],
263
298
  xAxisCalloutData: x,
264
299
  color: color,
265
300
  legend: legend,
@@ -283,17 +318,26 @@ var transformPlotlyJsonToVBCProps = function (input, colorMap, colorwayType, isD
283
318
  }
284
319
  // extract colors for each series only once
285
320
  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);
286
- var isXString = isStringArray(series.x);
321
+ var xValues = [];
322
+ var yValues = [];
323
+ series.x.forEach(function (xVal, index) {
324
+ var yVal = (0, exports.getNumberAtIndexOrDefault)(series.y, index);
325
+ if ((0, exports.isInvalidValue)(xVal) || (0, exports.isInvalidValue)(yVal)) {
326
+ return;
327
+ }
328
+ xValues.push(xVal);
329
+ yValues.push(yVal);
330
+ });
331
+ var isXString = isStringArray(xValues);
287
332
  // TODO: In case of a single bin, add an empty bin of the same size to prevent the
288
333
  // default bar width from being used and ensure the bar spans the full intended range.
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
+ 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);
290
335
  var yBins = xBins.map(function () { return []; });
291
336
  var total = 0;
292
- series.x.forEach(function (xVal, index) {
293
- var _a, _b;
337
+ xValues.forEach(function (xVal, index) {
294
338
  var binIdx = findBinIndex(xBins, xVal, isXString);
295
339
  if (binIdx !== -1) {
296
- yBins[binIdx].push((_b = (_a = series.y) === null || _a === void 0 ? void 0 : _a[index]) !== null && _b !== void 0 ? _b : 1);
340
+ yBins[binIdx].push(yValues[index]);
297
341
  }
298
342
  });
299
343
  var y = yBins.map(function (bin) {
@@ -333,12 +377,13 @@ var transformPlotlyJsonToScatterChartProps = function (input, isAreaChart, isSca
333
377
  var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
334
378
  var mode = 'tonexty';
335
379
  var _g = getLegendProps(input.data, input.layout), legends = _g.legends, hideLegend = _g.hideLegend;
336
- var chartData = input.data.map(function (series, index) {
337
- var _a, _b, _c, _d, _e, _f;
380
+ var chartData = input.data
381
+ .map(function (series, index) {
382
+ var _a, _b, _c, _d, _e, _f, _g;
338
383
  // extract colors for each series only once
339
384
  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);
340
385
  var xValues = series.x;
341
- var isString = typeof xValues[0] === 'string';
386
+ var isString = isStringArray(xValues);
342
387
  var isXDate = (0, chart_utilities_1.isDateArray)(xValues);
343
388
  var isXNumber = (0, chart_utilities_1.isNumberArray)(xValues);
344
389
  var legend = legends[index];
@@ -347,27 +392,50 @@ var transformPlotlyJsonToScatterChartProps = function (input, isAreaChart, isSca
347
392
  mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
348
393
  var lineOptions = getLineOptions(series.line);
349
394
  var dashType = ((_f = series.line) === null || _f === void 0 ? void 0 : _f.dash) || 'solid';
350
- var legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot' ? 'dottedLine' : 'default';
351
- return tslib_1.__assign(tslib_1.__assign({ legend: legend, legendShape: legendShape, data: xValues.map(function (x, i) {
352
- var _a, _b;
353
- return (tslib_1.__assign({ x: isString ? (isXDate ? new Date(x) : isXNumber ? parseFloat(x) : x) : x, y: series.y[i] }, (Array.isArray((_a = series.marker) === null || _a === void 0 ? void 0 : _a.size)
354
- ? { markerSize: series.marker.size[i] }
355
- : typeof ((_b = series.marker) === null || _b === void 0 ? void 0 : _b.size) === 'number'
356
- ? { markerSize: series.marker.size }
357
- : {})));
358
- }), color: seriesColor }, (lineOptions ? { lineOptions: lineOptions } : {})), { useSecondaryYScale: usesSecondaryYScale(series) });
359
- });
395
+ var legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot'
396
+ ? 'dottedLine'
397
+ : ((_g = series.mode) === null || _g === void 0 ? void 0 : _g.includes('markers'))
398
+ ? 'circle'
399
+ : 'default';
400
+ var validXYRanges = (0, exports.getValidXYRanges)(series);
401
+ return validXYRanges.map(function (_a, rangeIdx) {
402
+ var _b;
403
+ var rangeStart = _a[0], rangeEnd = _a[1];
404
+ var rangeXValues = xValues.slice(rangeStart, rangeEnd);
405
+ var rangeYValues = series.y.slice(rangeStart, rangeEnd);
406
+ var markerSizes = (0, chart_utilities_1.isArrayOrTypedArray)((_b = series.marker) === null || _b === void 0 ? void 0 : _b.size)
407
+ ? series.marker.size.slice(rangeStart, rangeEnd)
408
+ : [];
409
+ return {
410
+ legend: legend,
411
+ legendShape: legendShape,
412
+ data: rangeXValues.map(function (x, i) {
413
+ var _a, _b;
414
+ 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)
415
+ ? { markerSize: markerSizes[i] }
416
+ : typeof ((_b = series.marker) === null || _b === void 0 ? void 0 : _b.size) === 'number'
417
+ ? { markerSize: series.marker.size }
418
+ : {})));
419
+ }),
420
+ color: seriesColor,
421
+ lineOptions: tslib_1.__assign(tslib_1.__assign({}, (lineOptions !== null && lineOptions !== void 0 ? lineOptions : {})), { mode: series.mode }),
422
+ useSecondaryYScale: usesSecondaryYScale(series),
423
+ };
424
+ });
425
+ })
426
+ .flat();
360
427
  var yMinMaxValues = (0, utilities_1.findNumericMinMaxOfY)(chartData);
361
428
  var _h = getTitles(input.layout), chartTitle = _h.chartTitle, xAxisTitle = _h.xAxisTitle, yAxisTitle = _h.yAxisTitle;
429
+ var numDataPoints = chartData.reduce(function (total, lineChartPoints) { return total + lineChartPoints.data.length; }, 0);
362
430
  var chartProps = {
363
431
  chartTitle: chartTitle,
364
432
  lineChartData: chartData,
365
433
  };
366
434
  if (isAreaChart) {
367
- 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 });
435
+ 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 });
368
436
  }
369
437
  else {
370
- 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 });
438
+ 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 });
371
439
  }
372
440
  };
373
441
  exports.transformPlotlyJsonToScatterChartProps = transformPlotlyJsonToScatterChartProps;
@@ -382,14 +450,20 @@ var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, colorMap,
382
450
  var legend = legends[index];
383
451
  // resolve color for each legend's bars from the extracted colors
384
452
  var color = (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, index, legend, colorMap, isDarkTheme);
385
- return series.y.map(function (yValue, i) {
453
+ return series.y
454
+ .map(function (yValue, i) {
455
+ var _a;
456
+ if ((0, exports.isInvalidValue)((_a = series.x) === null || _a === void 0 ? void 0 : _a[i]) || (0, exports.isInvalidValue)(yValue)) {
457
+ return null;
458
+ }
386
459
  return {
387
460
  x: series.x[i],
388
461
  y: yValue,
389
462
  legend: legend,
390
463
  color: color,
391
464
  };
392
- });
465
+ })
466
+ .filter(function (point) { return point !== null; });
393
467
  })
394
468
  .reverse()
395
469
  .flat()
@@ -434,18 +508,30 @@ var transformPlotlyJsonToHeatmapProps = function (input) {
434
508
  var zMin = Number.POSITIVE_INFINITY;
435
509
  var zMax = Number.NEGATIVE_INFINITY;
436
510
  if (firstData.type === 'histogram2d') {
437
- var isXString_1 = isStringArray(firstData.x);
438
- var isYString_1 = isStringArray(firstData.y);
439
- var xBins_1 = createBins(firstData.x, (_a = firstData.xbins) === null || _a === void 0 ? void 0 : _a.start, (_b = firstData.xbins) === null || _b === void 0 ? void 0 : _b.end, (_c = firstData.xbins) === null || _c === void 0 ? void 0 : _c.size);
440
- var yBins_1 = createBins(firstData.y, (_d = firstData.ybins) === null || _d === void 0 ? void 0 : _d.start, (_e = firstData.ybins) === null || _e === void 0 ? void 0 : _e.end, (_f = firstData.ybins) === null || _f === void 0 ? void 0 : _f.size);
511
+ var xValues_1 = [];
512
+ var yValues_1 = [];
513
+ var zValues_1 = [];
514
+ (_a = firstData.x) === null || _a === void 0 ? void 0 : _a.forEach(function (xVal, index) {
515
+ var _a;
516
+ var zVal = (0, exports.getNumberAtIndexOrDefault)(firstData.z, index);
517
+ if ((0, exports.isInvalidValue)(xVal) || (0, exports.isInvalidValue)((_a = firstData.y) === null || _a === void 0 ? void 0 : _a[index]) || (0, exports.isInvalidValue)(zVal)) {
518
+ return;
519
+ }
520
+ xValues_1.push(xVal);
521
+ yValues_1.push(firstData.y[index]);
522
+ zValues_1.push(zVal);
523
+ });
524
+ var isXString_1 = isStringArray(xValues_1);
525
+ var isYString_1 = isStringArray(yValues_1);
526
+ 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);
527
+ 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);
441
528
  var zBins_1 = yBins_1.map(function () { return xBins_1.map(function () { return []; }); });
442
529
  var total_1 = 0;
443
- (_g = firstData.x) === null || _g === void 0 ? void 0 : _g.forEach(function (xVal, index) {
444
- var _a, _b, _c;
530
+ xValues_1.forEach(function (xVal, index) {
445
531
  var xBinIdx = findBinIndex(xBins_1, xVal, isXString_1);
446
- var yBinIdx = findBinIndex(yBins_1, (_a = firstData.y) === null || _a === void 0 ? void 0 : _a[index], isYString_1);
532
+ var yBinIdx = findBinIndex(yBins_1, yValues_1[index], isYString_1);
447
533
  if (xBinIdx !== -1 && yBinIdx !== -1) {
448
- zBins_1[yBinIdx][xBinIdx].push((_c = (_b = firstData.z) === null || _b === void 0 ? void 0 : _b[index]) !== null && _c !== void 0 ? _c : 1);
534
+ zBins_1[yBinIdx][xBinIdx].push(zValues_1[index]);
449
535
  }
450
536
  });
451
537
  var z_1 = zBins_1.map(function (row) {
@@ -532,13 +618,19 @@ var transformPlotlyJsonToSankeyProps = function (input, colorMap, colorwayType,
532
618
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
533
619
  var _m = input.data[0], link = _m.link, node = _m.node;
534
620
  var validLinks = ((_a = link === null || link === void 0 ? void 0 : link.value) !== null && _a !== void 0 ? _a : [])
535
- .map(function (val, index) { return ({
536
- value: val,
537
- source: link === null || link === void 0 ? void 0 : link.source[index],
538
- target: link === null || link === void 0 ? void 0 : link.target[index],
539
- }); })
621
+ .map(function (val, index) {
622
+ var _a, _b;
623
+ 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])) {
624
+ return null;
625
+ }
626
+ return {
627
+ value: val,
628
+ source: link === null || link === void 0 ? void 0 : link.source[index],
629
+ target: link === null || link === void 0 ? void 0 : link.target[index],
630
+ };
631
+ })
540
632
  // Filter out negative nodes, unequal nodes and self-references (circular links)
541
- .filter(function (x) { return x.source >= 0 && x.target >= 0 && x.source !== x.target; });
633
+ .filter(function (x) { return x !== null && x.source >= 0 && x.target >= 0 && x.source !== x.target; });
542
634
  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);
543
635
  var sankeyChartData = {
544
636
  nodes: (_e = node.label) === null || _e === void 0 ? void 0 : _e.map(function (label, index) {
@@ -683,16 +775,20 @@ var transformPlotlyJsonToChartTableProps = function (input, colorMap, isDarkThem
683
775
  };
684
776
  exports.transformPlotlyJsonToChartTableProps = transformPlotlyJsonToChartTableProps;
685
777
  var projectPolarToCartesian = function (input) {
778
+ var _a, _b, _c, _d;
686
779
  var projection = tslib_1.__assign({}, input);
687
780
  for (var sindex = 0; sindex < input.data.length; sindex++) {
688
781
  var series = input.data[sindex];
689
782
  series.x = [];
690
783
  series.y = [];
691
- for (var ptindex = 0; ptindex < series.r.length; ptindex++) {
784
+ for (var ptindex = 0; ptindex < ((_b = (_a = series.r) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0); ptindex++) {
785
+ 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])) {
786
+ continue;
787
+ }
692
788
  var thetaRad = (series.theta[ptindex] * Math.PI) / 180;
693
789
  var radius = series.r[ptindex];
694
- series.x[ptindex] = radius * Math.cos(thetaRad);
695
- series.y[ptindex] = radius * Math.sin(thetaRad);
790
+ series.x.push(radius * Math.cos(thetaRad));
791
+ series.y.push(radius * Math.sin(thetaRad));
696
792
  }
697
793
  projection.data[sindex] = series;
698
794
  }
@@ -780,7 +876,7 @@ function getLineOptions(line) {
780
876
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
781
877
  var isStringArray = function (arr) {
782
878
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
783
- return (0, chart_utilities_1.isArrayOfType)(arr, function (value) { return typeof value === 'string'; });
879
+ return (0, chart_utilities_1.isArrayOfType)(arr, function (value) { return typeof value === 'string' || value === null; });
784
880
  };
785
881
  // TODO: Use binary search to find the appropriate bin for numeric value.
786
882
  var findBinIndex = function (bins, value, isString) {
@@ -892,4 +988,40 @@ var getLegendProps = function (data, layout) {
892
988
  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,
893
989
  };
894
990
  };
991
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
992
+ var isInvalidValue = function (value) {
993
+ return typeof value === 'undefined' || value === null || (typeof value === 'number' && !isFinite(value));
994
+ };
995
+ exports.isInvalidValue = isInvalidValue;
996
+ var getNumberAtIndexOrDefault = function (data, index) {
997
+ if ((0, chart_utilities_1.isArrayOrTypedArray)(data)) {
998
+ if (typeof data[index] !== 'number' || !isFinite(data[index])) {
999
+ return;
1000
+ }
1001
+ return data[index];
1002
+ }
1003
+ return 1;
1004
+ };
1005
+ exports.getNumberAtIndexOrDefault = getNumberAtIndexOrDefault;
1006
+ var getValidXYRanges = function (series) {
1007
+ if (!(0, chart_utilities_1.isArrayOrTypedArray)(series.x) || !(0, chart_utilities_1.isArrayOrTypedArray)(series.y)) {
1008
+ return [];
1009
+ }
1010
+ var ranges = [];
1011
+ var start = 0;
1012
+ var end = 0;
1013
+ for (; end < series.x.length; end++) {
1014
+ if ((0, exports.isInvalidValue)(series.x[end]) || (0, exports.isInvalidValue)(series.y[end])) {
1015
+ if (end - start > 0) {
1016
+ ranges.push([start, end]);
1017
+ }
1018
+ start = end + 1;
1019
+ }
1020
+ }
1021
+ if (end - start > 0) {
1022
+ ranges.push([start, end]);
1023
+ }
1024
+ return ranges;
1025
+ };
1026
+ exports.getValidXYRanges = getValidXYRanges;
895
1027
  //# sourceMappingURL=PlotlySchemaAdapter.js.map