@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
@@ -53,7 +53,8 @@ var isMonth = function (possiblyMonthValue) {
53
53
  return parseFullMonth(possiblyMonthValue) !== null || parseShortMonth(possiblyMonthValue) !== null;
54
54
  };
55
55
  export var isMonthArray = function (data) {
56
- return isArrayOfType(data, isMonth);
56
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
57
+ return isArrayOfType(data, function (value) { return isMonth(value) || value === null; });
57
58
  };
58
59
  function getTitles(layout) {
59
60
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
@@ -74,19 +75,29 @@ export var correctYearMonth = function (xValues) {
74
75
  var parsedDate = "".concat(possiblyMonthValue, " 01, ").concat(presentYear);
75
76
  return isDate(parsedDate) ? new Date(parsedDate) : null;
76
77
  });
77
- for (var i = dates.length - 1; i > 0; i--) {
78
- var currentMonth = dates[i].getMonth();
79
- var previousMonth = dates[i - 1].getMonth();
80
- var currentYear = dates[i].getFullYear();
81
- var previousYear = dates[i - 1].getFullYear();
78
+ var filteredDateIndexPairs = dates.map(function (date, index) { return [date, index]; }).filter(function (_a) {
79
+ var date = _a[0];
80
+ return date !== null;
81
+ });
82
+ for (var i = filteredDateIndexPairs.length - 1; i > 0; i--) {
83
+ var currentDate = filteredDateIndexPairs[i][0];
84
+ var previousDate = filteredDateIndexPairs[i - 1][0];
85
+ var currentMonth = currentDate.getMonth();
86
+ var previousMonth = previousDate.getMonth();
87
+ var currentYear = currentDate.getFullYear();
88
+ var previousYear = previousDate.getFullYear();
82
89
  if (previousMonth >= currentMonth) {
83
- dates[i - 1].setFullYear(dates[i].getFullYear() - 1);
90
+ filteredDateIndexPairs[i - 1][0].setFullYear(currentYear - 1);
84
91
  }
85
92
  else if (previousYear > currentYear) {
86
- dates[i - 1].setFullYear(currentYear);
93
+ filteredDateIndexPairs[i - 1][0].setFullYear(currentYear);
87
94
  }
95
+ dates[filteredDateIndexPairs[i - 1][1]] = filteredDateIndexPairs[i - 1][0];
88
96
  }
89
97
  xValues = xValues.map(function (month, index) {
98
+ if (dates[index] === null) {
99
+ return null;
100
+ }
90
101
  return "".concat(month, " 01, ").concat(dates[index].getFullYear());
91
102
  });
92
103
  return xValues;
@@ -145,20 +156,22 @@ export var transformPlotlyJsonToDonutProps = function (input, colorMap, colorway
145
156
  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);
146
157
  var mapLegendToDataPoint = {};
147
158
  (_e = firstData.labels) === null || _e === void 0 ? void 0 : _e.forEach(function (label, index) {
148
- var _a;
159
+ var value = getNumberAtIndexOrDefault(firstData.values, index);
160
+ if (isInvalidValue(value) || value < 0) {
161
+ return;
162
+ }
163
+ var legend = "".concat(label);
149
164
  // resolve color for each legend from the extracted colors
150
- var color = resolveColor(colors, index, label, colorMap, isDarkTheme);
151
- //ToDo how to handle string data?
152
- var value = typeof ((_a = firstData.values) === null || _a === void 0 ? void 0 : _a[index]) === 'number' ? firstData.values[index] : 1;
153
- if (!mapLegendToDataPoint[label]) {
154
- mapLegendToDataPoint[label] = {
155
- legend: label,
165
+ var color = resolveColor(colors, index, legend, colorMap, isDarkTheme);
166
+ if (!mapLegendToDataPoint[legend]) {
167
+ mapLegendToDataPoint[legend] = {
168
+ legend: legend,
156
169
  data: value,
157
170
  color: color,
158
171
  };
159
172
  }
160
173
  else {
161
- mapLegendToDataPoint[label].data += value;
174
+ mapLegendToDataPoint[legend].data += value;
162
175
  }
163
176
  });
164
177
  var width = (_g = (_f = input.layout) === null || _f === void 0 ? void 0 : _f.width) !== null && _g !== void 0 ? _g : 440;
@@ -190,46 +203,65 @@ export var transformPlotlyJsonToVSBCProps = function (input, colorMap, colorwayT
190
203
  var _a, _b, _c;
191
204
  var mapXToDataPoints = {};
192
205
  var yMaxValue = 0;
206
+ var yMinValue = 0;
193
207
  var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
194
208
  var _d = getLegendProps(input.data, input.layout), legends = _d.legends, hideLegend = _d.hideLegend;
195
209
  input.data.forEach(function (series, index1) {
196
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
210
+ var _a, _b, _c, _d, _e, _f, _g, _h;
197
211
  var isXYearCategory = isYearArray(series.x); // Consider year as categorical not numeric continuous axis
198
212
  // extract bar colors for each series only once
199
213
  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
214
  // extract line colors for each series only once
201
215
  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) {
203
- var _a, _b, _c;
204
- if (!mapXToDataPoints[x]) {
205
- mapXToDataPoints[x] = { xAxisPoint: isXYearCategory ? x.toString() : x, chartData: [], lineData: [] };
206
- }
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);
210
- var yVal = (_b = (_a = series.y) === null || _a === void 0 ? void 0 : _a[index2]) !== null && _b !== void 0 ? _b : 0;
211
- if (series.type === 'bar') {
212
- mapXToDataPoints[x].chartData.push({
213
- legend: legend,
214
- data: yVal,
215
- color: color,
216
- });
217
- yMaxValue = Math.max(yMaxValue, yVal);
218
- }
219
- else if (series.type === 'scatter' || !!fallbackVSBC) {
220
- var lineColor = resolveColor(extractedLineColors, index1, legend, colorMap, isDarkTheme);
221
- var lineOptions = getLineOptions(series.line);
222
- var dashType = ((_c = series.line) === null || _c === void 0 ? void 0 : _c.dash) || 'solid';
223
- var legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot' ? 'dottedLine' : 'default';
224
- mapXToDataPoints[x].lineData.push(__assign(__assign({ legend: legend, legendShape: legendShape, y: yVal, color: lineColor }, (lineOptions ? { lineOptions: lineOptions } : {})), { useSecondaryYScale: usesSecondaryYScale(series) }));
225
- if (!usesSecondaryYScale(series)) {
216
+ var validXYRanges = getValidXYRanges(series);
217
+ validXYRanges.forEach(function (_a, rangeIdx) {
218
+ var rangeStart = _a[0], rangeEnd = _a[1];
219
+ var rangeXValues = series.x.slice(rangeStart, rangeEnd);
220
+ var rangeYValues = series.y.slice(rangeStart, rangeEnd);
221
+ rangeXValues.forEach(function (x, index2) {
222
+ var _a, _b;
223
+ if (!mapXToDataPoints[x]) {
224
+ mapXToDataPoints[x] = { xAxisPoint: isXYearCategory ? x.toString() : x, chartData: [], lineData: [] };
225
+ }
226
+ var legend = legends[index1];
227
+ // resolve color for each legend's bars from the extracted colors
228
+ var color = resolveColor(extractedBarColors, index1, legend, colorMap, isDarkTheme);
229
+ var yVal = rangeYValues[index2];
230
+ if (series.type === 'bar') {
231
+ mapXToDataPoints[x].chartData.push({
232
+ legend: legend,
233
+ data: yVal,
234
+ color: color,
235
+ });
226
236
  yMaxValue = Math.max(yMaxValue, yVal);
227
237
  }
228
- }
238
+ else if (series.type === 'scatter' || !!fallbackVSBC) {
239
+ var lineColor = resolveColor(extractedLineColors, index1, legend, colorMap, isDarkTheme);
240
+ var lineOptions = getLineOptions(series.line);
241
+ var dashType = ((_a = series.line) === null || _a === void 0 ? void 0 : _a.dash) || 'solid';
242
+ var legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot'
243
+ ? 'dottedLine'
244
+ : ((_b = series.mode) === null || _b === void 0 ? void 0 : _b.includes('markers'))
245
+ ? 'circle'
246
+ : 'default';
247
+ mapXToDataPoints[x].lineData.push({
248
+ legend: legend + (validXYRanges.length > 1 ? ".".concat(rangeIdx + 1) : ''),
249
+ legendShape: legendShape,
250
+ y: yVal,
251
+ color: lineColor,
252
+ lineOptions: __assign(__assign({}, (lineOptions !== null && lineOptions !== void 0 ? lineOptions : {})), { mode: series.mode }),
253
+ useSecondaryYScale: usesSecondaryYScale(series),
254
+ });
255
+ if (!usesSecondaryYScale(series)) {
256
+ yMaxValue = Math.max(yMaxValue, yVal);
257
+ yMinValue = Math.min(yMinValue, yVal);
258
+ }
259
+ }
260
+ });
229
261
  });
230
262
  });
231
263
  var _e = getTitles(input.layout), chartTitle = _e.chartTitle, xAxisTitle = _e.xAxisTitle, yAxisTitle = _e.yAxisTitle;
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 });
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', yMaxValue: yMaxValue, yMinValue: yMinValue, chartTitle: chartTitle, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle, mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true, supportNegativeData: true, barGapMax: 2 });
233
265
  };
234
266
  export var transformPlotlyJsonToGVBCProps = function (input, colorMap, colorwayType, isDarkTheme) {
235
267
  var _a, _b, _c;
@@ -241,7 +273,10 @@ export var transformPlotlyJsonToGVBCProps = function (input, colorMap, colorwayT
241
273
  // extract colors for each series only once
242
274
  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
275
  (_e = series.x) === null || _e === void 0 ? void 0 : _e.forEach(function (x, xIndex) {
244
- var _a, _b;
276
+ var _a;
277
+ if (isInvalidValue(x) || isInvalidValue((_a = series.y) === null || _a === void 0 ? void 0 : _a[xIndex])) {
278
+ return;
279
+ }
245
280
  if (!mapXToDataPoints[x]) {
246
281
  mapXToDataPoints[x] = { name: x.toString(), series: [] };
247
282
  }
@@ -251,7 +286,7 @@ export var transformPlotlyJsonToGVBCProps = function (input, colorMap, colorwayT
251
286
  var color = resolveColor(extractedColors, index1, legend, colorMap, isDarkTheme);
252
287
  mapXToDataPoints[x].series.push({
253
288
  key: legend,
254
- data: (_b = (_a = series.y) === null || _a === void 0 ? void 0 : _a[xIndex]) !== null && _b !== void 0 ? _b : 0,
289
+ data: series.y[xIndex],
255
290
  xAxisCalloutData: x,
256
291
  color: color,
257
292
  legend: legend,
@@ -274,17 +309,26 @@ export var transformPlotlyJsonToVBCProps = function (input, colorMap, colorwayTy
274
309
  }
275
310
  // extract colors for each series only once
276
311
  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);
277
- var isXString = isStringArray(series.x);
312
+ var xValues = [];
313
+ var yValues = [];
314
+ series.x.forEach(function (xVal, index) {
315
+ var yVal = getNumberAtIndexOrDefault(series.y, index);
316
+ if (isInvalidValue(xVal) || 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(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);
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
- series.x.forEach(function (xVal, index) {
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((_b = (_a = series.y) === null || _a === void 0 ? void 0 : _a[index]) !== null && _b !== void 0 ? _b : 1);
331
+ yBins[binIdx].push(yValues[index]);
288
332
  }
289
333
  });
290
334
  var y = yBins.map(function (bin) {
@@ -323,12 +367,13 @@ export var transformPlotlyJsonToScatterChartProps = function (input, isAreaChart
323
367
  var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
324
368
  var mode = 'tonexty';
325
369
  var _g = getLegendProps(input.data, input.layout), legends = _g.legends, hideLegend = _g.hideLegend;
326
- var chartData = input.data.map(function (series, index) {
327
- var _a, _b, _c, _d, _e, _f;
370
+ var chartData = input.data
371
+ .map(function (series, index) {
372
+ var _a, _b, _c, _d, _e, _f, _g;
328
373
  // extract colors for each series only once
329
374
  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);
330
375
  var xValues = series.x;
331
- var isString = typeof xValues[0] === 'string';
376
+ var isString = isStringArray(xValues);
332
377
  var isXDate = isDateArray(xValues);
333
378
  var isXNumber = isNumberArray(xValues);
334
379
  var legend = legends[index];
@@ -337,27 +382,50 @@ export var transformPlotlyJsonToScatterChartProps = function (input, isAreaChart
337
382
  mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
338
383
  var lineOptions = getLineOptions(series.line);
339
384
  var dashType = ((_f = series.line) === null || _f === void 0 ? void 0 : _f.dash) || 'solid';
340
- var legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot' ? 'dottedLine' : 'default';
341
- return __assign(__assign({ legend: legend, legendShape: legendShape, data: xValues.map(function (x, i) {
342
- var _a, _b;
343
- return (__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)
344
- ? { markerSize: series.marker.size[i] }
345
- : typeof ((_b = series.marker) === null || _b === void 0 ? void 0 : _b.size) === 'number'
346
- ? { markerSize: series.marker.size }
347
- : {})));
348
- }), color: seriesColor }, (lineOptions ? { lineOptions: lineOptions } : {})), { useSecondaryYScale: usesSecondaryYScale(series) });
349
- });
385
+ var legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot'
386
+ ? 'dottedLine'
387
+ : ((_g = series.mode) === null || _g === void 0 ? void 0 : _g.includes('markers'))
388
+ ? 'circle'
389
+ : 'default';
390
+ var validXYRanges = getValidXYRanges(series);
391
+ return validXYRanges.map(function (_a, rangeIdx) {
392
+ var _b;
393
+ var rangeStart = _a[0], rangeEnd = _a[1];
394
+ var rangeXValues = xValues.slice(rangeStart, rangeEnd);
395
+ var rangeYValues = series.y.slice(rangeStart, rangeEnd);
396
+ var markerSizes = isArrayOrTypedArray((_b = series.marker) === null || _b === void 0 ? void 0 : _b.size)
397
+ ? series.marker.size.slice(rangeStart, rangeEnd)
398
+ : [];
399
+ return {
400
+ legend: legend,
401
+ legendShape: legendShape,
402
+ data: rangeXValues.map(function (x, i) {
403
+ var _a, _b;
404
+ return (__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)
405
+ ? { markerSize: markerSizes[i] }
406
+ : typeof ((_b = series.marker) === null || _b === void 0 ? void 0 : _b.size) === 'number'
407
+ ? { markerSize: series.marker.size }
408
+ : {})));
409
+ }),
410
+ color: seriesColor,
411
+ lineOptions: __assign(__assign({}, (lineOptions !== null && lineOptions !== void 0 ? lineOptions : {})), { mode: series.mode }),
412
+ useSecondaryYScale: usesSecondaryYScale(series),
413
+ };
414
+ });
415
+ })
416
+ .flat();
350
417
  var yMinMaxValues = findNumericMinMaxOfY(chartData);
351
418
  var _h = getTitles(input.layout), chartTitle = _h.chartTitle, xAxisTitle = _h.xAxisTitle, yAxisTitle = _h.yAxisTitle;
419
+ var numDataPoints = chartData.reduce(function (total, lineChartPoints) { return total + lineChartPoints.data.length; }, 0);
352
420
  var chartProps = {
353
421
  chartTitle: chartTitle,
354
422
  lineChartData: chartData,
355
423
  };
356
424
  if (isAreaChart) {
357
- return __assign(__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 });
425
+ return __assign(__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 });
358
426
  }
359
427
  else {
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 });
428
+ 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, optimizeLargeData: numDataPoints > 1000 });
361
429
  }
362
430
  };
363
431
  export var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, colorMap, colorwayType, isDarkTheme) {
@@ -371,14 +439,20 @@ export var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, co
371
439
  var legend = legends[index];
372
440
  // resolve color for each legend's bars from the extracted colors
373
441
  var color = resolveColor(extractedColors, index, legend, colorMap, isDarkTheme);
374
- return series.y.map(function (yValue, i) {
442
+ return series.y
443
+ .map(function (yValue, i) {
444
+ var _a;
445
+ if (isInvalidValue((_a = series.x) === null || _a === void 0 ? void 0 : _a[i]) || isInvalidValue(yValue)) {
446
+ return null;
447
+ }
375
448
  return {
376
449
  x: series.x[i],
377
450
  y: yValue,
378
451
  legend: legend,
379
452
  color: color,
380
453
  };
381
- });
454
+ })
455
+ .filter(function (point) { return point !== null; });
382
456
  })
383
457
  .reverse()
384
458
  .flat()
@@ -422,18 +496,30 @@ export var transformPlotlyJsonToHeatmapProps = function (input) {
422
496
  var zMin = Number.POSITIVE_INFINITY;
423
497
  var zMax = Number.NEGATIVE_INFINITY;
424
498
  if (firstData.type === 'histogram2d') {
425
- var isXString_1 = isStringArray(firstData.x);
426
- var isYString_1 = isStringArray(firstData.y);
427
- 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);
428
- 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);
499
+ var xValues_1 = [];
500
+ var yValues_1 = [];
501
+ var zValues_1 = [];
502
+ (_a = firstData.x) === null || _a === void 0 ? void 0 : _a.forEach(function (xVal, index) {
503
+ var _a;
504
+ var zVal = getNumberAtIndexOrDefault(firstData.z, index);
505
+ if (isInvalidValue(xVal) || isInvalidValue((_a = firstData.y) === null || _a === void 0 ? void 0 : _a[index]) || isInvalidValue(zVal)) {
506
+ return;
507
+ }
508
+ xValues_1.push(xVal);
509
+ yValues_1.push(firstData.y[index]);
510
+ zValues_1.push(zVal);
511
+ });
512
+ var isXString_1 = isStringArray(xValues_1);
513
+ var isYString_1 = isStringArray(yValues_1);
514
+ 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);
515
+ 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);
429
516
  var zBins_1 = yBins_1.map(function () { return xBins_1.map(function () { return []; }); });
430
517
  var total_1 = 0;
431
- (_g = firstData.x) === null || _g === void 0 ? void 0 : _g.forEach(function (xVal, index) {
432
- var _a, _b, _c;
518
+ xValues_1.forEach(function (xVal, index) {
433
519
  var xBinIdx = findBinIndex(xBins_1, xVal, isXString_1);
434
- var yBinIdx = findBinIndex(yBins_1, (_a = firstData.y) === null || _a === void 0 ? void 0 : _a[index], isYString_1);
520
+ var yBinIdx = findBinIndex(yBins_1, yValues_1[index], isYString_1);
435
521
  if (xBinIdx !== -1 && yBinIdx !== -1) {
436
- zBins_1[yBinIdx][xBinIdx].push((_c = (_b = firstData.z) === null || _b === void 0 ? void 0 : _b[index]) !== null && _c !== void 0 ? _c : 1);
522
+ zBins_1[yBinIdx][xBinIdx].push(zValues_1[index]);
437
523
  }
438
524
  });
439
525
  var z_1 = zBins_1.map(function (row) {
@@ -519,13 +605,19 @@ export var transformPlotlyJsonToSankeyProps = function (input, colorMap, colorwa
519
605
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
520
606
  var _m = input.data[0], link = _m.link, node = _m.node;
521
607
  var validLinks = ((_a = link === null || link === void 0 ? void 0 : link.value) !== null && _a !== void 0 ? _a : [])
522
- .map(function (val, index) { return ({
523
- value: val,
524
- source: link === null || link === void 0 ? void 0 : link.source[index],
525
- target: link === null || link === void 0 ? void 0 : link.target[index],
526
- }); })
608
+ .map(function (val, index) {
609
+ var _a, _b;
610
+ if (isInvalidValue(val) || isInvalidValue((_a = link === null || link === void 0 ? void 0 : link.source) === null || _a === void 0 ? void 0 : _a[index]) || isInvalidValue((_b = link === null || link === void 0 ? void 0 : link.target) === null || _b === void 0 ? void 0 : _b[index])) {
611
+ return null;
612
+ }
613
+ return {
614
+ value: val,
615
+ source: link === null || link === void 0 ? void 0 : link.source[index],
616
+ target: link === null || link === void 0 ? void 0 : link.target[index],
617
+ };
618
+ })
527
619
  // Filter out negative nodes, unequal nodes and self-references (circular links)
528
- .filter(function (x) { return x.source >= 0 && x.target >= 0 && x.source !== x.target; });
620
+ .filter(function (x) { return x !== null && x.source >= 0 && x.target >= 0 && x.source !== x.target; });
529
621
  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);
530
622
  var sankeyChartData = {
531
623
  nodes: (_e = node.label) === null || _e === void 0 ? void 0 : _e.map(function (label, index) {
@@ -667,16 +759,20 @@ export var transformPlotlyJsonToChartTableProps = function (input, colorMap, isD
667
759
  };
668
760
  };
669
761
  export var projectPolarToCartesian = function (input) {
762
+ var _a, _b, _c, _d;
670
763
  var projection = __assign({}, input);
671
764
  for (var sindex = 0; sindex < input.data.length; sindex++) {
672
765
  var series = input.data[sindex];
673
766
  series.x = [];
674
767
  series.y = [];
675
- for (var ptindex = 0; ptindex < series.r.length; ptindex++) {
768
+ for (var ptindex = 0; ptindex < ((_b = (_a = series.r) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0); ptindex++) {
769
+ if (isInvalidValue((_c = series.theta) === null || _c === void 0 ? void 0 : _c[ptindex]) || isInvalidValue((_d = series.r) === null || _d === void 0 ? void 0 : _d[ptindex])) {
770
+ continue;
771
+ }
676
772
  var thetaRad = (series.theta[ptindex] * Math.PI) / 180;
677
773
  var radius = series.r[ptindex];
678
- series.x[ptindex] = radius * Math.cos(thetaRad);
679
- series.y[ptindex] = radius * Math.sin(thetaRad);
774
+ series.x.push(radius * Math.cos(thetaRad));
775
+ series.y.push(radius * Math.sin(thetaRad));
680
776
  }
681
777
  projection.data[sindex] = series;
682
778
  }
@@ -762,7 +858,7 @@ function getLineOptions(line) {
762
858
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
763
859
  var isStringArray = function (arr) {
764
860
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
765
- return isArrayOfType(arr, function (value) { return typeof value === 'string'; });
861
+ return isArrayOfType(arr, function (value) { return typeof value === 'string' || value === null; });
766
862
  };
767
863
  // TODO: Use binary search to find the appropriate bin for numeric value.
768
864
  var findBinIndex = function (bins, value, isString) {
@@ -874,4 +970,37 @@ var getLegendProps = function (data, layout) {
874
970
  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,
875
971
  };
876
972
  };
973
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
974
+ export var isInvalidValue = function (value) {
975
+ return typeof value === 'undefined' || value === null || (typeof value === 'number' && !isFinite(value));
976
+ };
977
+ export var getNumberAtIndexOrDefault = function (data, index) {
978
+ if (isArrayOrTypedArray(data)) {
979
+ if (typeof data[index] !== 'number' || !isFinite(data[index])) {
980
+ return;
981
+ }
982
+ return data[index];
983
+ }
984
+ return 1;
985
+ };
986
+ export var getValidXYRanges = function (series) {
987
+ if (!isArrayOrTypedArray(series.x) || !isArrayOrTypedArray(series.y)) {
988
+ return [];
989
+ }
990
+ var ranges = [];
991
+ var start = 0;
992
+ var end = 0;
993
+ for (; end < series.x.length; end++) {
994
+ if (isInvalidValue(series.x[end]) || isInvalidValue(series.y[end])) {
995
+ if (end - start > 0) {
996
+ ranges.push([start, end]);
997
+ }
998
+ start = end + 1;
999
+ }
1000
+ }
1001
+ if (end - start > 0) {
1002
+ ranges.push([start, end]);
1003
+ }
1004
+ return ranges;
1005
+ };
877
1006
  //# sourceMappingURL=PlotlySchemaAdapter.js.map