@fluentui/react-charting 5.24.13 → 5.24.15

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 (65) hide show
  1. package/CHANGELOG.json +64 -1
  2. package/CHANGELOG.md +23 -2
  3. package/dist/react-charting.d.ts +26 -17
  4. package/dist/react-charting.js +1 -1
  5. package/dist/react-charting.min.js +1 -1
  6. package/etc/react-charting.api.md +1 -0
  7. package/lib/Utilities.js +19 -1
  8. package/lib/Utilities.js.map +1 -1
  9. package/lib/components/CommonComponents/CartesianChart.base.js +6 -6
  10. package/lib/components/CommonComponents/CartesianChart.base.js.map +1 -1
  11. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +45 -12
  12. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  13. package/lib/components/GanttChart/GanttChart.base.js +210 -158
  14. package/lib/components/GanttChart/GanttChart.base.js.map +1 -1
  15. package/lib/components/GanttChart/GanttChart.types.d.ts +23 -13
  16. package/lib/components/GanttChart/GanttChart.types.js.map +1 -1
  17. package/lib/components/LineChart/LineChart.base.js +6 -11
  18. package/lib/components/LineChart/LineChart.base.js.map +1 -1
  19. package/lib/components/ScatterChart/ScatterChart.base.js +4 -9
  20. package/lib/components/ScatterChart/ScatterChart.base.js.map +1 -1
  21. package/lib/types/IDataPoint.d.ts +3 -4
  22. package/lib/types/IDataPoint.js.map +1 -1
  23. package/lib/utilities/scatterpolar-utils.d.ts +7 -4
  24. package/lib/utilities/scatterpolar-utils.js +19 -2
  25. package/lib/utilities/scatterpolar-utils.js.map +1 -1
  26. package/lib-amd/Utilities.js +9 -0
  27. package/lib-amd/Utilities.js.map +1 -1
  28. package/lib-amd/components/CommonComponents/CartesianChart.base.js +6 -6
  29. package/lib-amd/components/CommonComponents/CartesianChart.base.js.map +1 -1
  30. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +45 -12
  31. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  32. package/lib-amd/components/GanttChart/GanttChart.base.js +210 -158
  33. package/lib-amd/components/GanttChart/GanttChart.base.js.map +1 -1
  34. package/lib-amd/components/GanttChart/GanttChart.types.d.ts +23 -13
  35. package/lib-amd/components/GanttChart/GanttChart.types.js.map +1 -1
  36. package/lib-amd/components/LineChart/LineChart.base.js +6 -11
  37. package/lib-amd/components/LineChart/LineChart.base.js.map +1 -1
  38. package/lib-amd/components/ScatterChart/ScatterChart.base.js +4 -9
  39. package/lib-amd/components/ScatterChart/ScatterChart.base.js.map +1 -1
  40. package/lib-amd/types/IDataPoint.d.ts +3 -4
  41. package/lib-amd/types/IDataPoint.js.map +1 -1
  42. package/lib-amd/utilities/scatterpolar-utils.d.ts +7 -4
  43. package/lib-amd/utilities/scatterpolar-utils.js +21 -3
  44. package/lib-amd/utilities/scatterpolar-utils.js.map +1 -1
  45. package/lib-commonjs/Utilities.js +9 -0
  46. package/lib-commonjs/Utilities.js.map +1 -1
  47. package/lib-commonjs/components/CommonComponents/CartesianChart.base.js +6 -6
  48. package/lib-commonjs/components/CommonComponents/CartesianChart.base.js.map +1 -1
  49. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +45 -12
  50. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  51. package/lib-commonjs/components/GanttChart/GanttChart.base.js +210 -158
  52. package/lib-commonjs/components/GanttChart/GanttChart.base.js.map +1 -1
  53. package/lib-commonjs/components/GanttChart/GanttChart.types.d.ts +23 -13
  54. package/lib-commonjs/components/GanttChart/GanttChart.types.js.map +1 -1
  55. package/lib-commonjs/components/LineChart/LineChart.base.js +6 -11
  56. package/lib-commonjs/components/LineChart/LineChart.base.js.map +1 -1
  57. package/lib-commonjs/components/ScatterChart/ScatterChart.base.js +4 -9
  58. package/lib-commonjs/components/ScatterChart/ScatterChart.base.js.map +1 -1
  59. package/lib-commonjs/types/IDataPoint.d.ts +3 -4
  60. package/lib-commonjs/types/IDataPoint.js.map +1 -1
  61. package/lib-commonjs/utilities/scatterpolar-utils.d.ts +7 -4
  62. package/lib-commonjs/utilities/scatterpolar-utils.js +21 -3
  63. package/lib-commonjs/utilities/scatterpolar-utils.js.map +1 -1
  64. package/package.json +2 -2
  65. package/src/components/GanttChart/GanttChart.types.ts +24 -13
@@ -340,7 +340,7 @@ var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorMap, col
340
340
  });
341
341
  });
342
342
  var vsbcData = Object.values(mapXToDataPoints);
343
- return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ data: vsbcData, 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, mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true, supportNegativeData: true, barGapMax: 2, showYAxisLables: true, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, wrapXAxisLables: typeof ((_d = vsbcData[0]) === null || _d === void 0 ? void 0 : _d.xAxisPoint) === 'string' }), getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getXAxisTickFormat(input.data[0], input.layout)), yAxisTickFormat);
343
+ return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ data: vsbcData, 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, mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true, supportNegativeData: true, barGapMax: 2, showYAxisLables: true, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, wrapXAxisLables: typeof ((_d = vsbcData[0]) === null || _d === void 0 ? void 0 : _d.xAxisPoint) === 'string' }), getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getYMinMaxValues(input.data[0], input.layout)), getXAxisTickFormat(input.data[0], input.layout)), yAxisTickFormat);
344
344
  };
345
345
  exports.transformPlotlyJsonToVSBCProps = transformPlotlyJsonToVSBCProps;
346
346
  var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
@@ -501,7 +501,7 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
501
501
  var legendShape = getLegendShape(series);
502
502
  var validXYRanges = (0, exports.getValidXYRanges)(series);
503
503
  return validXYRanges.map(function (_a, rangeIdx) {
504
- var _b, _c, _d;
504
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k;
505
505
  var rangeStart = _a[0], rangeEnd = _a[1];
506
506
  var rangeXValues = xValues.slice(rangeStart, rangeEnd);
507
507
  var rangeYValues = series.y.slice(rangeStart, rangeEnd);
@@ -521,10 +521,13 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
521
521
  : {})), (textValues ? { text: textValues[i] } : {})), { yAxisCalloutData: getFormattedCalloutYData(rangeYValues[i], yAxisTickFormat) }));
522
522
  }),
523
523
  color: (_c = (0, d3_color_1.rgb)(seriesColor).copy({ opacity: seriesOpacity }).formatHex8()) !== null && _c !== void 0 ? _c : seriesColor,
524
- lineOptions: tslib_1.__assign(tslib_1.__assign({}, (lineOptions !== null && lineOptions !== void 0 ? lineOptions : {})), { mode: series.type !== 'scatterpolar' ? series.mode : 'scatterpolar',
525
- // originXOffset is not typed on Layout, but may be present in input.layout as a part of projection of
526
- // scatter polar coordingates to cartesian coordinates
527
- originXOffset: (_d = input.layout) === null || _d === void 0 ? void 0 : _d.__polarOriginX }),
524
+ lineOptions: tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, (lineOptions !== null && lineOptions !== void 0 ? lineOptions : {})), { mode: series.type !== 'scatterpolar' ? series.mode : 'scatterpolar' }), (series.type === 'scatterpolar'
525
+ ? {
526
+ originXOffset: (_d = input.layout) === null || _d === void 0 ? void 0 : _d.__polarOriginX,
527
+ direction: (_g = (_f = (_e = input.layout) === null || _e === void 0 ? void 0 : _e.polar) === null || _f === void 0 ? void 0 : _f.angularaxis) === null || _g === void 0 ? void 0 : _g.direction,
528
+ rotation: (_k = (_j = (_h = input.layout) === null || _h === void 0 ? void 0 : _h.polar) === null || _j === void 0 ? void 0 : _j.angularaxis) === null || _k === void 0 ? void 0 : _k.rotation,
529
+ }
530
+ : {})),
528
531
  useSecondaryYScale: usesSecondaryYScale(series, input.layout),
529
532
  };
530
533
  });
@@ -612,7 +615,7 @@ var transformPlotlyJsonToGanttChartProps = function (input, isMultiPlot, colorMa
612
615
  var isXDate = ((_f = (_e = input.layout) === null || _e === void 0 ? void 0 : _e.xaxis) === null || _f === void 0 ? void 0 : _f.type) === 'date' || (0, chart_utilities_1.isDateArray)(series.x);
613
616
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
614
617
  var convertXValueToNumber = function (value) {
615
- return (0, chart_utilities_1.isInvalidValue)(value) ? 0 : isXDate ? new Date(value).getTime() : value;
618
+ return (0, chart_utilities_1.isInvalidValue)(value) ? 0 : isXDate ? +parseLocalDate(value) : +value;
616
619
  };
617
620
  return series.y
618
621
  .map(function (yVal, i) {
@@ -1137,7 +1140,7 @@ var transformPlotlyJsonToFunnelChartProps = function (input, isMultiPlot, colorM
1137
1140
  };
1138
1141
  exports.transformPlotlyJsonToFunnelChartProps = transformPlotlyJsonToFunnelChartProps;
1139
1142
  var projectPolarToCartesian = function (input) {
1140
- var _a, _b;
1143
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1141
1144
  var projection = tslib_1.__assign({}, input);
1142
1145
  // 1. Find the global min and max radius across all series
1143
1146
  var minRadius = 0;
@@ -1174,6 +1177,9 @@ var projectPolarToCartesian = function (input) {
1174
1177
  projection.data[sindex] = series;
1175
1178
  return "continue";
1176
1179
  }
1180
+ // retrieve polar axis settings
1181
+ var dirMultiplier = ((_c = (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.polar) === null || _b === void 0 ? void 0 : _b.angularaxis) === null || _c === void 0 ? void 0 : _c.direction) === 'clockwise' ? -1 : 1;
1182
+ var startAngleInRad = (((_g = (_f = (_e = (_d = input.layout) === null || _d === void 0 ? void 0 : _d.polar) === null || _e === void 0 ? void 0 : _e.angularaxis) === null || _f === void 0 ? void 0 : _f.rotation) !== null && _g !== void 0 ? _g : 0) * Math.PI) / 180;
1177
1183
  // Compute tick positions if categorical
1178
1184
  var uniqueTheta = [];
1179
1185
  var categorical = false;
@@ -1190,10 +1196,10 @@ var projectPolarToCartesian = function (input) {
1190
1196
  if (categorical) {
1191
1197
  var idx = uniqueTheta.indexOf(thetas[ptindex]);
1192
1198
  var step = (2 * Math.PI) / uniqueTheta.length;
1193
- thetaRad = idx * step;
1199
+ thetaRad = startAngleInRad + dirMultiplier * idx * step;
1194
1200
  }
1195
1201
  else {
1196
- thetaRad = (thetas[ptindex] * Math.PI) / 180;
1202
+ thetaRad = startAngleInRad + dirMultiplier * ((thetas[ptindex] * Math.PI) / 180);
1197
1203
  }
1198
1204
  // 5. Shift only the polar origin (not the cartesian)
1199
1205
  var rawRadius = rVals[ptindex];
@@ -1247,7 +1253,7 @@ var projectPolarToCartesian = function (input) {
1247
1253
  }
1248
1254
  }
1249
1255
  // 10. Customize layout for perfect square with absolute positioning
1250
- var size = ((_a = input.layout) === null || _a === void 0 ? void 0 : _a.width) || ((_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) || 500;
1256
+ var size = ((_h = input.layout) === null || _h === void 0 ? void 0 : _h.width) || ((_j = input.layout) === null || _j === void 0 ? void 0 : _j.height) || 500;
1251
1257
  projection.layout = tslib_1.__assign(tslib_1.__assign({}, projection.layout), { width: size, height: size });
1252
1258
  // Attach originX as custom properties
1253
1259
  projection.layout.__polarOriginX = originX !== null && originX !== void 0 ? originX : undefined;
@@ -1731,11 +1737,38 @@ var getAxisCategoryOrderProps = function (data, layout) {
1731
1737
  }
1732
1738
  if (!(ax === null || ax === void 0 ? void 0 : ax.categoryorder) || ax.categoryorder === 'trace' || ax.categoryorder === 'array') {
1733
1739
  var categoriesInTraceOrder = Array.from(new Set(values));
1734
- result[propName] = categoriesInTraceOrder;
1740
+ result[propName] = (ax === null || ax === void 0 ? void 0 : ax.autorange) === 'reversed' ? categoriesInTraceOrder.reverse() : categoriesInTraceOrder;
1735
1741
  return;
1736
1742
  }
1737
1743
  result[propName] = ax.categoryorder;
1738
1744
  });
1739
1745
  return result;
1740
1746
  };
1747
+ /**
1748
+ * This is experimental. Use it only with valid datetime strings to verify if they conform to the ISO 8601 format.
1749
+ */
1750
+ var isoDateRegex = /^\d{4}(-\d{2}(-\d{2})?)?(T\d{2}:\d{2}(:\d{2}(\.\d{1,9})?)?(Z)?)?$/;
1751
+ /**
1752
+ * We want to display localized date and time in the charts, so the useUTC prop is set to false.
1753
+ * But this can sometimes cause the formatters to display the datetime incorrectly.
1754
+ * To work around this issue, we use this function to adjust datetime strings so that they are always interpreted
1755
+ * as local time, allowing the formatters to produce the correct output.
1756
+ *
1757
+ * FIXME: The formatters should always produce a clear and accurate localized output, regardless of the
1758
+ * format used to create the date object.
1759
+ */
1760
+ var parseLocalDate = function (value) {
1761
+ if (typeof value === 'string') {
1762
+ var match = value.match(isoDateRegex);
1763
+ if (match) {
1764
+ if (!match[3]) {
1765
+ value += 'T00:00';
1766
+ }
1767
+ else if (match[6]) {
1768
+ value = value.replace('Z', '');
1769
+ }
1770
+ }
1771
+ }
1772
+ return new Date(value);
1773
+ };
1741
1774
  //# sourceMappingURL=PlotlySchemaAdapter.js.map