@fluentui/react-charting 5.23.91 → 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 (50) hide show
  1. package/CHANGELOG.json +40 -1
  2. package/CHANGELOG.md +15 -2
  3. package/dist/react-charting.d.ts +5 -1
  4. package/dist/react-charting.js +1 -1
  5. package/dist/react-charting.min.js +1 -1
  6. package/etc/react-charting.api.md +2 -0
  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 +213 -86
  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/types/IDataPoint.d.ts +4 -0
  18. package/lib/types/IDataPoint.js.map +1 -1
  19. package/lib/utilities/image-export-utils.js +18 -1
  20. package/lib/utilities/image-export-utils.js.map +1 -1
  21. package/lib-amd/components/DeclarativeChart/DeclarativeChart.js +9 -2
  22. package/lib-amd/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  23. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +4 -1
  24. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +217 -87
  25. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  26. package/lib-amd/components/LineChart/LineChart.base.d.ts +2 -0
  27. package/lib-amd/components/LineChart/LineChart.base.js +58 -17
  28. package/lib-amd/components/LineChart/LineChart.base.js.map +1 -1
  29. package/lib-amd/components/LineChart/LineChart.types.d.ts +1 -1
  30. package/lib-amd/components/LineChart/LineChart.types.js.map +1 -1
  31. package/lib-amd/types/IDataPoint.d.ts +4 -0
  32. package/lib-amd/types/IDataPoint.js.map +1 -1
  33. package/lib-amd/utilities/image-export-utils.js +18 -1
  34. package/lib-amd/utilities/image-export-utils.js.map +1 -1
  35. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +9 -2
  36. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  37. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +4 -1
  38. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +217 -87
  39. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  40. package/lib-commonjs/components/LineChart/LineChart.base.d.ts +2 -0
  41. package/lib-commonjs/components/LineChart/LineChart.base.js +58 -17
  42. package/lib-commonjs/components/LineChart/LineChart.base.js.map +1 -1
  43. package/lib-commonjs/components/LineChart/LineChart.types.d.ts +1 -1
  44. package/lib-commonjs/components/LineChart/LineChart.types.js.map +1 -1
  45. package/lib-commonjs/types/IDataPoint.d.ts +4 -0
  46. package/lib-commonjs/types/IDataPoint.js.map +1 -1
  47. package/lib-commonjs/utilities/image-export-utils.js +18 -1
  48. package/lib-commonjs/utilities/image-export-utils.js.map +1 -1
  49. package/package.json +2 -2
  50. package/src/components/LineChart/LineChart.types.ts +1 -1
@@ -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
- return (0, chart_utilities_1.isArrayOfType)(data, isMonth);
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
- for (var i = dates.length - 1; i > 0; i--) {
73
- var currentMonth = dates[i].getMonth();
74
- var previousMonth = dates[i - 1].getMonth();
75
- var currentYear = dates[i].getFullYear();
76
- var previousYear = dates[i - 1].getFullYear();
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
- dates[i - 1].setFullYear(dates[i].getFullYear() - 1);
85
+ filteredDateIndexPairs[i - 1][0].setFullYear(currentYear - 1);
79
86
  }
80
87
  else if (previousYear > currentYear) {
81
- dates[i - 1].setFullYear(currentYear);
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 _a;
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, label, colorMap, isDarkTheme);
148
- //ToDo how to handle string data?
149
- var value = typeof ((_a = firstData.values) === null || _a === void 0 ? void 0 : _a[index]) === 'number' ? firstData.values[index] : 1;
150
- if (!mapLegendToDataPoint[label]) {
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[label].data += value;
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;
@@ -192,44 +205,61 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "../../utilities/
192
205
  var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
193
206
  var _d = getLegendProps(input.data, input.layout), legends = _d.legends, hideLegend = _d.hideLegend;
194
207
  input.data.forEach(function (series, index1) {
195
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
208
+ var _a, _b, _c, _d, _e, _f, _g, _h;
196
209
  var isXYearCategory = (0, chart_utilities_1.isYearArray)(series.x); // Consider year as categorical not numeric continuous axis
197
210
  // extract bar colors for each series only once
198
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);
199
212
  // extract line colors for each series only once
200
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);
201
- (_j = series.x) === null || _j === void 0 ? void 0 : _j.forEach(function (x, index2) {
202
- var _a, _b, _c;
203
- if (!mapXToDataPoints[x]) {
204
- mapXToDataPoints[x] = { xAxisPoint: isXYearCategory ? x.toString() : x, chartData: [], lineData: [] };
205
- }
206
- var legend = legends[index1];
207
- // resolve color for each legend's bars from the extracted colors
208
- var color = (0, PlotlyColorAdapter_1.resolveColor)(extractedBarColors, index1, legend, colorMap, isDarkTheme);
209
- var yVal = (_b = (_a = series.y) === null || _a === void 0 ? void 0 : _a[index2]) !== null && _b !== void 0 ? _b : 0;
210
- if (series.type === 'bar') {
211
- mapXToDataPoints[x].chartData.push({
212
- legend: legend,
213
- data: yVal,
214
- color: color,
215
- });
216
- yMaxValue = Math.max(yMaxValue, yVal);
217
- }
218
- else if (series.type === 'scatter' || !!fallbackVSBC) {
219
- var lineColor = (0, PlotlyColorAdapter_1.resolveColor)(extractedLineColors, index1, legend, colorMap, isDarkTheme);
220
- var lineOptions = getLineOptions(series.line);
221
- var dashType = ((_c = series.line) === null || _c === void 0 ? void 0 : _c.dash) || 'solid';
222
- var legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot' ? 'dottedLine' : 'default';
223
- mapXToDataPoints[x].lineData.push(tslib_1.__assign(tslib_1.__assign({ legend: legend, legendShape: legendShape, y: yVal, color: lineColor }, (lineOptions ? { lineOptions: lineOptions } : {})), { useSecondaryYScale: usesSecondaryYScale(series) }));
224
- 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
+ });
225
234
  yMaxValue = Math.max(yMaxValue, yVal);
226
- yMinValue = Math.min(yMinValue, yVal);
227
235
  }
228
- }
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
+ });
229
259
  });
230
260
  });
231
261
  var _e = getTitles(input.layout), chartTitle = _e.chartTitle, xAxisTitle = _e.xAxisTitle, yAxisTitle = _e.yAxisTitle;
232
- 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 });
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 });
233
263
  };
234
264
  exports.transformPlotlyJsonToVSBCProps = transformPlotlyJsonToVSBCProps;
235
265
  var transformPlotlyJsonToGVBCProps = function (input, colorMap, colorwayType, isDarkTheme) {
@@ -242,7 +272,10 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "../../utilities/
242
272
  // extract colors for each series only once
243
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);
244
274
  (_e = series.x) === null || _e === void 0 ? void 0 : _e.forEach(function (x, xIndex) {
245
- var _a, _b;
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
+ }
246
279
  if (!mapXToDataPoints[x]) {
247
280
  mapXToDataPoints[x] = { name: x.toString(), series: [] };
248
281
  }
@@ -252,7 +285,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "../../utilities/
252
285
  var color = (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, index1, legend, colorMap, isDarkTheme);
253
286
  mapXToDataPoints[x].series.push({
254
287
  key: legend,
255
- data: (_b = (_a = series.y) === null || _a === void 0 ? void 0 : _a[xIndex]) !== null && _b !== void 0 ? _b : 0,
288
+ data: series.y[xIndex],
256
289
  xAxisCalloutData: x,
257
290
  color: color,
258
291
  legend: legend,
@@ -276,17 +309,26 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "../../utilities/
276
309
  }
277
310
  // extract colors for each series only once
278
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);
279
- var isXString = isStringArray(series.x);
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);
280
323
  // TODO: In case of a single bin, add an empty bin of the same size to prevent the
281
324
  // default bar width from being used and ensure the bar spans the full intended range.
282
- 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);
283
326
  var yBins = xBins.map(function () { return []; });
284
327
  var total = 0;
285
- series.x.forEach(function (xVal, index) {
286
- var _a, _b;
328
+ xValues.forEach(function (xVal, index) {
287
329
  var binIdx = findBinIndex(xBins, xVal, isXString);
288
330
  if (binIdx !== -1) {
289
- 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]);
290
332
  }
291
333
  });
292
334
  var y = yBins.map(function (bin) {
@@ -326,12 +368,13 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "../../utilities/
326
368
  var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
327
369
  var mode = 'tonexty';
328
370
  var _g = getLegendProps(input.data, input.layout), legends = _g.legends, hideLegend = _g.hideLegend;
329
- var chartData = input.data.map(function (series, index) {
330
- var _a, _b, _c, _d, _e, _f;
371
+ var chartData = input.data
372
+ .map(function (series, index) {
373
+ var _a, _b, _c, _d, _e, _f, _g;
331
374
  // extract colors for each series only once
332
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);
333
376
  var xValues = series.x;
334
- var isString = typeof xValues[0] === 'string';
377
+ var isString = isStringArray(xValues);
335
378
  var isXDate = (0, chart_utilities_1.isDateArray)(xValues);
336
379
  var isXNumber = (0, chart_utilities_1.isNumberArray)(xValues);
337
380
  var legend = legends[index];
@@ -340,27 +383,50 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "../../utilities/
340
383
  mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
341
384
  var lineOptions = getLineOptions(series.line);
342
385
  var dashType = ((_f = series.line) === null || _f === void 0 ? void 0 : _f.dash) || 'solid';
343
- var legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot' ? 'dottedLine' : 'default';
344
- return tslib_1.__assign(tslib_1.__assign({ legend: legend, legendShape: legendShape, data: xValues.map(function (x, i) {
345
- var _a, _b;
346
- 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)
347
- ? { markerSize: series.marker.size[i] }
348
- : typeof ((_b = series.marker) === null || _b === void 0 ? void 0 : _b.size) === 'number'
349
- ? { markerSize: series.marker.size }
350
- : {})));
351
- }), color: seriesColor }, (lineOptions ? { lineOptions: lineOptions } : {})), { useSecondaryYScale: usesSecondaryYScale(series) });
352
- });
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();
353
418
  var yMinMaxValues = (0, utilities_1.findNumericMinMaxOfY)(chartData);
354
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);
355
421
  var chartProps = {
356
422
  chartTitle: chartTitle,
357
423
  lineChartData: chartData,
358
424
  };
359
425
  if (isAreaChart) {
360
- 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 });
361
427
  }
362
428
  else {
363
- 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 });
364
430
  }
365
431
  };
366
432
  exports.transformPlotlyJsonToScatterChartProps = transformPlotlyJsonToScatterChartProps;
@@ -375,14 +441,20 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "../../utilities/
375
441
  var legend = legends[index];
376
442
  // resolve color for each legend's bars from the extracted colors
377
443
  var color = (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, index, legend, colorMap, isDarkTheme);
378
- return series.y.map(function (yValue, i) {
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
+ }
379
450
  return {
380
451
  x: series.x[i],
381
452
  y: yValue,
382
453
  legend: legend,
383
454
  color: color,
384
455
  };
385
- });
456
+ })
457
+ .filter(function (point) { return point !== null; });
386
458
  })
387
459
  .reverse()
388
460
  .flat()
@@ -427,18 +499,30 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "../../utilities/
427
499
  var zMin = Number.POSITIVE_INFINITY;
428
500
  var zMax = Number.NEGATIVE_INFINITY;
429
501
  if (firstData.type === 'histogram2d') {
430
- var isXString_1 = isStringArray(firstData.x);
431
- var isYString_1 = isStringArray(firstData.y);
432
- 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);
433
- 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);
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);
434
519
  var zBins_1 = yBins_1.map(function () { return xBins_1.map(function () { return []; }); });
435
520
  var total_1 = 0;
436
- (_g = firstData.x) === null || _g === void 0 ? void 0 : _g.forEach(function (xVal, index) {
437
- var _a, _b, _c;
521
+ xValues_1.forEach(function (xVal, index) {
438
522
  var xBinIdx = findBinIndex(xBins_1, xVal, isXString_1);
439
- var yBinIdx = findBinIndex(yBins_1, (_a = firstData.y) === null || _a === void 0 ? void 0 : _a[index], isYString_1);
523
+ var yBinIdx = findBinIndex(yBins_1, yValues_1[index], isYString_1);
440
524
  if (xBinIdx !== -1 && yBinIdx !== -1) {
441
- zBins_1[yBinIdx][xBinIdx].push((_c = (_b = firstData.z) === null || _b === void 0 ? void 0 : _b[index]) !== null && _c !== void 0 ? _c : 1);
525
+ zBins_1[yBinIdx][xBinIdx].push(zValues_1[index]);
442
526
  }
443
527
  });
444
528
  var z_1 = zBins_1.map(function (row) {
@@ -525,13 +609,19 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "../../utilities/
525
609
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
526
610
  var _m = input.data[0], link = _m.link, node = _m.node;
527
611
  var validLinks = ((_a = link === null || link === void 0 ? void 0 : link.value) !== null && _a !== void 0 ? _a : [])
528
- .map(function (val, index) { return ({
529
- value: val,
530
- source: link === null || link === void 0 ? void 0 : link.source[index],
531
- target: link === null || link === void 0 ? void 0 : link.target[index],
532
- }); })
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
+ })
533
623
  // Filter out negative nodes, unequal nodes and self-references (circular links)
534
- .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; });
535
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);
536
626
  var sankeyChartData = {
537
627
  nodes: (_e = node.label) === null || _e === void 0 ? void 0 : _e.map(function (label, index) {
@@ -676,16 +766,20 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "../../utilities/
676
766
  };
677
767
  exports.transformPlotlyJsonToChartTableProps = transformPlotlyJsonToChartTableProps;
678
768
  var projectPolarToCartesian = function (input) {
769
+ var _a, _b, _c, _d;
679
770
  var projection = tslib_1.__assign({}, input);
680
771
  for (var sindex = 0; sindex < input.data.length; sindex++) {
681
772
  var series = input.data[sindex];
682
773
  series.x = [];
683
774
  series.y = [];
684
- 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
+ }
685
779
  var thetaRad = (series.theta[ptindex] * Math.PI) / 180;
686
780
  var radius = series.r[ptindex];
687
- series.x[ptindex] = radius * Math.cos(thetaRad);
688
- series.y[ptindex] = radius * Math.sin(thetaRad);
781
+ series.x.push(radius * Math.cos(thetaRad));
782
+ series.y.push(radius * Math.sin(thetaRad));
689
783
  }
690
784
  projection.data[sindex] = series;
691
785
  }
@@ -773,7 +867,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "../../utilities/
773
867
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
774
868
  var isStringArray = function (arr) {
775
869
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
776
- 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; });
777
871
  };
778
872
  // TODO: Use binary search to find the appropriate bin for numeric value.
779
873
  var findBinIndex = function (bins, value, isString) {
@@ -885,5 +979,41 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "../../utilities/
885
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,
886
980
  };
887
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;
888
1018
  });
889
1019
  //# sourceMappingURL=PlotlySchemaAdapter.js.map