@fluentui/react-charts 0.0.0-nightly-20250826-2140.1 → 0.0.0-nightly-20250827-0407.1

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 (158) hide show
  1. package/CHANGELOG.md +48 -15
  2. package/dist/index.d.ts +15 -1
  3. package/lib/components/AreaChart/AreaChart.js +4 -1
  4. package/lib/components/AreaChart/AreaChart.js.map +1 -1
  5. package/lib/components/AreaChart/useAreaChartStyles.styles.js +2 -2
  6. package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
  7. package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js +3 -15
  8. package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
  9. package/lib/components/ChartTable/ChartTable.js +87 -6
  10. package/lib/components/ChartTable/ChartTable.js.map +1 -1
  11. package/lib/components/CommonComponents/CartesianChart.js +24 -24
  12. package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
  13. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +17 -14
  14. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  15. package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +6 -33
  16. package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
  17. package/lib/components/DeclarativeChart/DeclarativeChart.js +42 -16
  18. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  19. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +20 -1
  20. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
  21. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +493 -259
  22. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  23. package/lib/components/DonutChart/DonutChart.js +6 -1
  24. package/lib/components/DonutChart/DonutChart.js.map +1 -1
  25. package/lib/components/DonutChart/DonutChart.types.js.map +1 -1
  26. package/lib/components/DonutChart/useDonutChartStyles.styles.js +21 -4
  27. package/lib/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
  28. package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js +8 -4
  29. package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
  30. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +23 -4
  31. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  32. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +4 -17
  33. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  34. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +4 -21
  35. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
  36. package/lib/components/HeatMapChart/HeatMapChart.js +175 -114
  37. package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
  38. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +26 -6
  39. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  40. package/lib/components/LineChart/LineChart.js +137 -82
  41. package/lib/components/LineChart/LineChart.js.map +1 -1
  42. package/lib/components/LineChart/LineChart.types.js.map +1 -1
  43. package/lib/components/LineChart/useLineChartStyles.styles.js +23 -10
  44. package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  45. package/lib/components/LineChart/useLineChartStyles.styles.raw.js +4 -21
  46. package/lib/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
  47. package/lib/components/SankeyChart/useSankeyChartStyles.styles.js +12 -25
  48. package/lib/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
  49. package/lib/components/SankeyChart/useSankeyChartStyles.styles.raw.js +2 -12
  50. package/lib/components/SankeyChart/useSankeyChartStyles.styles.raw.js.map +1 -1
  51. package/lib/components/ScatterChart/ScatterChart.js +95 -59
  52. package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
  53. package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -1
  54. package/lib/components/ScatterChart/useScatterChartStyles.styles.js +27 -7
  55. package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  56. package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js +8 -14
  57. package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
  58. package/lib/components/VerticalBarChart/VerticalBarChart.js +27 -4
  59. package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  60. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +8 -6
  61. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  62. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +5 -19
  63. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
  64. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +61 -44
  65. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  66. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +7 -6
  67. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
  68. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +4 -19
  69. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
  70. package/lib/utilities/Common.styles.js +47 -0
  71. package/lib/utilities/Common.styles.js.map +1 -0
  72. package/lib/utilities/Common.styles.raw.js +47 -0
  73. package/lib/utilities/Common.styles.raw.js.map +1 -0
  74. package/lib/utilities/SVGTooltipText.js.map +1 -1
  75. package/lib/utilities/index.js +1 -0
  76. package/lib/utilities/index.js.map +1 -1
  77. package/lib/utilities/scatterpolar-utils.js +63 -0
  78. package/lib/utilities/scatterpolar-utils.js.map +1 -0
  79. package/lib/utilities/utilities.js +32 -37
  80. package/lib/utilities/utilities.js.map +1 -1
  81. package/lib-commonjs/components/AreaChart/AreaChart.js +4 -1
  82. package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
  83. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
  84. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js +2 -14
  85. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
  86. package/lib-commonjs/components/ChartTable/ChartTable.js +87 -6
  87. package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -1
  88. package/lib-commonjs/components/CommonComponents/CartesianChart.js +24 -24
  89. package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
  90. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +15 -13
  91. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  92. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +4 -32
  93. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
  94. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +41 -15
  95. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  96. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +23 -1
  97. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
  98. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +500 -257
  99. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  100. package/lib-commonjs/components/DonutChart/DonutChart.js +6 -1
  101. package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
  102. package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -1
  103. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js +32 -4
  104. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
  105. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js +8 -4
  106. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
  107. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +22 -3
  108. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  109. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +2 -19
  110. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  111. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +3 -20
  112. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
  113. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +174 -113
  114. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
  115. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +25 -5
  116. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  117. package/lib-commonjs/components/LineChart/LineChart.js +136 -81
  118. package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
  119. package/lib-commonjs/components/LineChart/LineChart.types.js.map +1 -1
  120. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js +30 -9
  121. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  122. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js +2 -20
  123. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
  124. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js +23 -33
  125. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
  126. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.raw.js +1 -12
  127. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.raw.js.map +1 -1
  128. package/lib-commonjs/components/ScatterChart/ScatterChart.js +94 -58
  129. package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
  130. package/lib-commonjs/components/ScatterChart/ScatterChart.types.js.map +1 -1
  131. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js +37 -5
  132. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  133. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js +7 -13
  134. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
  135. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +26 -3
  136. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  137. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +5 -3
  138. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  139. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +3 -17
  140. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
  141. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +60 -43
  142. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  143. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +5 -3
  144. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
  145. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +3 -18
  146. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
  147. package/lib-commonjs/utilities/Common.styles.js +71 -0
  148. package/lib-commonjs/utilities/Common.styles.js.map +1 -0
  149. package/lib-commonjs/utilities/Common.styles.raw.js +71 -0
  150. package/lib-commonjs/utilities/Common.styles.raw.js.map +1 -0
  151. package/lib-commonjs/utilities/SVGTooltipText.js.map +1 -1
  152. package/lib-commonjs/utilities/index.js +1 -0
  153. package/lib-commonjs/utilities/index.js.map +1 -1
  154. package/lib-commonjs/utilities/scatterpolar-utils.js +78 -0
  155. package/lib-commonjs/utilities/scatterpolar-utils.js.map +1 -0
  156. package/lib-commonjs/utilities/utilities.js +28 -40
  157. package/lib-commonjs/utilities/utilities.js.map +1 -1
  158. package/package.json +12 -12
@@ -6,13 +6,17 @@ import { scaleLinear as d3ScaleLinear, scaleBand as d3ScaleBand, scaleUtc as d3S
6
6
  import { useId } from '@fluentui/react-utilities';
7
7
  import { tokens } from '@fluentui/react-theme';
8
8
  import { CartesianChart, ChartPopover, Legends } from '../../index';
9
- import { ChartTypes, getAccessibleDataObject, XAxisTypes, getTypeOfAxis, tooltipOfAxislabels, formatScientificLimitWidth, getBarWidth, getScalePadding, isScalePaddingDefined, calculateAppropriateBarWidth, formatDate, areArraysEqual, calculateLongestLabelWidth, useRtl, DataVizPalette, getColorFromToken, findVSBCNumericMinMaxOfY, YAxisType, createNumericYAxis, domainRangeOfDateForAreaLineVerticalBarChart, domainRangeOfVSBCNumeric, domainRangeOfXStringAxis, createStringYAxis, calcTotalWidth, calcBandwidth, calcRequiredWidth } from '../../utilities/index';
9
+ import { ChartTypes, getAccessibleDataObject, XAxisTypes, getTypeOfAxis, tooltipOfAxislabels, formatScientificLimitWidth, getBarWidth, getScalePadding, isScalePaddingDefined, calculateAppropriateBarWidth, formatDate, areArraysEqual, calculateLongestLabelWidth, useRtl, DataVizPalette, getColorFromToken, findVSBCNumericMinMaxOfY, YAxisType, createNumericYAxis, domainRangeOfDateForAreaLineVerticalBarChart, domainRangeOfVSBCNumeric, domainRangeOfXStringAxis, createStringYAxis, calcTotalWidth, calcBandwidth, calcRequiredWidth, sortAxisCategories } from '../../utilities/index';
10
10
  import { toImage } from '../../utilities/image-export-utils';
11
11
  import { formatDateToLocaleString } from '@fluentui/chart-utilities';
12
12
  const barGapMultiplier = 0.2;
13
13
  const barGapMin = 1;
14
14
  const MIN_DOMAIN_MARGIN = 8;
15
- export const VerticalStackedBarChart = (props)=>{
15
+ export const VerticalStackedBarChart = /*#__PURE__*/ React.forwardRef((props = {
16
+ xAxisCategoryOrder: 'default',
17
+ yAxisCategoryOrder: 'default',
18
+ data: []
19
+ }, forwardedRef)=>{
16
20
  var _props_legendProps;
17
21
  const _isRtl = useRtl();
18
22
  const _createLegendsForLine = (data)=>_getLineLegends(data);
@@ -241,9 +245,7 @@ export const VerticalStackedBarChart = (props)=>{
241
245
  _initYAxisParams();
242
246
  }
243
247
  function _createDataSetLayer() {
244
- const tempArr = [];
245
248
  const dataset = _points.map((singlePointData)=>{
246
- tempArr.push(singlePointData.xAxisPoint);
247
249
  if (_yAxisType === YAxisType.StringAxis) {
248
250
  return {
249
251
  x: singlePointData.xAxisPoint,
@@ -259,7 +261,7 @@ export const VerticalStackedBarChart = (props)=>{
259
261
  y: total
260
262
  };
261
263
  });
262
- _xAxisLabels = tempArr;
264
+ _xAxisLabels = _getOrderedXAxisLabels();
263
265
  return dataset;
264
266
  }
265
267
  function _onLegendHover(legendTitle) {
@@ -294,16 +296,16 @@ export const VerticalStackedBarChart = (props)=>{
294
296
  }
295
297
  }
296
298
  /**
297
- * This function checks if the given legend is highlighted or not.
298
- * A legend can be highlighted in 2 ways:
299
- * 1. selection: if the user clicks on it
300
- * 2. hovering: if there is no selected legend and the user hovers over it
301
- */ function _isLegendHighlighted(legendTitle) {
299
+ * This function checks if the given legend is highlighted or not.
300
+ * A legend can be highlighted in 2 ways:
301
+ * 1. selection: if the user clicks on it
302
+ * 2. hovering: if there is no selected legend and the user hovers over it
303
+ */ function _isLegendHighlighted(legendTitle) {
302
304
  return _getHighlightedLegend().includes(legendTitle);
303
305
  }
304
306
  /**
305
- * This function checks if none of the legends is selected or hovered.
306
- */ function _noLegendHighlighted() {
307
+ * This function checks if none of the legends is selected or hovered.
308
+ */ function _noLegendHighlighted() {
307
309
  return _getHighlightedLegend().length === 0;
308
310
  }
309
311
  function _getAriaLabel(singleChartData, point, isLinePoint) {
@@ -944,40 +946,13 @@ export const VerticalStackedBarChart = (props)=>{
944
946
  }
945
947
  });
946
948
  }
947
- if (_yAxisType === YAxisType.StringAxis) {
948
- const legendToYValues = {};
949
- _points.forEach((xPoint)=>{
950
- xPoint.chartData.forEach((bar)=>{
951
- if (!legendToYValues[bar.legend]) {
952
- legendToYValues[bar.legend] = [
953
- `${bar.data}`
954
- ];
955
- } else {
956
- legendToYValues[bar.legend].push(`${bar.data}`);
957
- }
958
- });
959
- });
960
- const yAxisLabels = new Set();
961
- Object.values(legendToYValues).forEach((yValues)=>{
962
- yValues.forEach((yVal)=>{
963
- yAxisLabels.add(yVal);
964
- });
965
- });
966
- Object.values(_lineObject).forEach((linePoints)=>{
967
- linePoints.forEach((linePoint)=>{
968
- if (!linePoint.useSecondaryYScale) {
969
- yAxisLabels.add(`${linePoint.y}`);
970
- }
971
- });
972
- });
973
- _yAxisLabels = Array.from(yAxisLabels);
974
- }
949
+ _yAxisLabels = _getOrderedYAxisLabels();
975
950
  }
976
951
  function _getYDomainMargins(containerHeight) {
977
952
  /**
978
- * Specifies the extra top margin to apply above the highest y-axis tick label.
979
- * Useful when stacked bars extend beyond the combined height of all y-axis labels (or categories).
980
- */ let yAxisTickMarginTop = 0;
953
+ * Specifies the extra top margin to apply above the highest y-axis tick label.
954
+ * Useful when stacked bars extend beyond the combined height of all y-axis labels (or categories).
955
+ */ let yAxisTickMarginTop = 0;
981
956
  /** Total height available to render the bars */ const totalHeight = containerHeight - _margins.bottom - _margins.top;
982
957
  if (_yAxisType === YAxisType.StringAxis) {
983
958
  /** Maximum height of the stacked bars, expressed in multiples of the height of a y-axis label (or category) */ let maxBarHeightInLabels = 0;
@@ -996,6 +971,48 @@ export const VerticalStackedBarChart = (props)=>{
996
971
  top: _margins.top + yAxisTickMarginTop
997
972
  };
998
973
  }
974
+ function _getOrderedXAxisLabels() {
975
+ if (_xAxisType !== XAxisTypes.StringAxis) {
976
+ return [];
977
+ }
978
+ return sortAxisCategories(_mapCategoryToValues(), props.xAxisCategoryOrder);
979
+ }
980
+ function _getOrderedYAxisLabels() {
981
+ if (_yAxisType !== YAxisType.StringAxis) {
982
+ return [];
983
+ }
984
+ return sortAxisCategories(_mapCategoryToValues(true), props.yAxisCategoryOrder);
985
+ }
986
+ function _mapCategoryToValues(isYAxis = false) {
987
+ const categoryToValues = {};
988
+ _points.forEach((point)=>{
989
+ var _point_lineData;
990
+ point.chartData.forEach((bar)=>{
991
+ const category = isYAxis ? bar.data : point.xAxisPoint;
992
+ const value = isYAxis ? point.xAxisPoint : bar.data;
993
+ if (!categoryToValues[category]) {
994
+ categoryToValues[category] = [];
995
+ }
996
+ if (typeof value === 'number') {
997
+ categoryToValues[category].push(value);
998
+ }
999
+ });
1000
+ (_point_lineData = point.lineData) === null || _point_lineData === void 0 ? void 0 : _point_lineData.forEach((linePoint)=>{
1001
+ if (isYAxis && linePoint.useSecondaryYScale) {
1002
+ return;
1003
+ }
1004
+ const category = isYAxis ? linePoint.y : point.xAxisPoint;
1005
+ const value = isYAxis ? point.xAxisPoint : linePoint.y;
1006
+ if (!categoryToValues[category]) {
1007
+ categoryToValues[category] = [];
1008
+ }
1009
+ if (typeof value === 'number') {
1010
+ categoryToValues[category].push(value);
1011
+ }
1012
+ });
1013
+ });
1014
+ return categoryToValues;
1015
+ }
999
1016
  if (!_isChartEmpty()) {
1000
1017
  _adjustProps();
1001
1018
  const _isHavingLines = props.data.some((item)=>item.lineData && item.lineData.length > 0);
@@ -1070,5 +1087,5 @@ export const VerticalStackedBarChart = (props)=>{
1070
1087
  },
1071
1088
  "aria-label": 'Graph has no data to display'
1072
1089
  });
1073
- };
1090
+ });
1074
1091
  VerticalStackedBarChart.displayName = 'VerticalStackedBarChart';