@fluentui/react-charting 5.24.3 → 5.24.5

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 (170) hide show
  1. package/CHANGELOG.json +85 -1
  2. package/CHANGELOG.md +29 -2
  3. package/config/tests.js +0 -12
  4. package/dist/react-charting.d.ts +38 -1
  5. package/dist/react-charting.js +1 -1
  6. package/dist/react-charting.min.js +1 -1
  7. package/etc/react-charting.api.md +8 -1
  8. package/lib/components/AreaChart/AreaChart.base.d.ts +1 -0
  9. package/lib/components/AreaChart/AreaChart.base.js +4 -1
  10. package/lib/components/AreaChart/AreaChart.base.js.map +1 -1
  11. package/lib/components/CommonComponents/CartesianChart.base.js +14 -13
  12. package/lib/components/CommonComponents/CartesianChart.base.js.map +1 -1
  13. package/lib/components/CommonComponents/CartesianChart.styles.js +41 -37
  14. package/lib/components/CommonComponents/CartesianChart.styles.js.map +1 -1
  15. package/lib/components/CommonComponents/CartesianChart.types.d.ts +12 -2
  16. package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
  17. package/lib/components/DeclarativeChart/DeclarativeChart.js +38 -16
  18. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  19. package/lib/components/DeclarativeChart/PlotlyColorAdapter.d.ts +2 -1
  20. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +9 -1
  21. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
  22. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +13 -3
  23. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +276 -199
  24. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  25. package/lib/components/DonutChart/DonutChart.base.js +1 -0
  26. package/lib/components/DonutChart/DonutChart.base.js.map +1 -1
  27. package/lib/components/DonutChart/DonutChart.styles.js +18 -0
  28. package/lib/components/DonutChart/DonutChart.styles.js.map +1 -1
  29. package/lib/components/DonutChart/DonutChart.types.d.ts +4 -0
  30. package/lib/components/DonutChart/DonutChart.types.js.map +1 -1
  31. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.d.ts +2 -0
  32. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +25 -4
  33. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
  34. package/lib/components/HeatMapChart/HeatMapChart.base.d.ts +7 -0
  35. package/lib/components/HeatMapChart/HeatMapChart.base.js +95 -37
  36. package/lib/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
  37. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.d.ts +3 -0
  38. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +24 -3
  39. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
  40. package/lib/components/ScatterChart/ScatterChart.base.js +84 -55
  41. package/lib/components/ScatterChart/ScatterChart.base.js.map +1 -1
  42. package/lib/components/ScatterChart/ScatterChart.styles.js +12 -0
  43. package/lib/components/ScatterChart/ScatterChart.styles.js.map +1 -1
  44. package/lib/components/ScatterChart/ScatterChart.types.d.ts +5 -0
  45. package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -1
  46. package/lib/components/VerticalBarChart/VerticalBarChart.base.d.ts +2 -0
  47. package/lib/components/VerticalBarChart/VerticalBarChart.base.js +30 -7
  48. package/lib/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
  49. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.d.ts +3 -0
  50. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +51 -32
  51. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
  52. package/lib/index.d.ts +1 -1
  53. package/lib/index.js.map +1 -1
  54. package/lib/types/IDataPoint.d.ts +18 -0
  55. package/lib/types/IDataPoint.js.map +1 -1
  56. package/lib/utilities/SVGTooltipText.js +3 -3
  57. package/lib/utilities/SVGTooltipText.js.map +1 -1
  58. package/lib/utilities/utilities.d.ts +6 -3
  59. package/lib/utilities/utilities.js +58 -29
  60. package/lib/utilities/utilities.js.map +1 -1
  61. package/lib-amd/components/AreaChart/AreaChart.base.d.ts +1 -0
  62. package/lib-amd/components/AreaChart/AreaChart.base.js +4 -1
  63. package/lib-amd/components/AreaChart/AreaChart.base.js.map +1 -1
  64. package/lib-amd/components/CommonComponents/CartesianChart.base.js +14 -13
  65. package/lib-amd/components/CommonComponents/CartesianChart.base.js.map +1 -1
  66. package/lib-amd/components/CommonComponents/CartesianChart.styles.js +41 -37
  67. package/lib-amd/components/CommonComponents/CartesianChart.styles.js.map +1 -1
  68. package/lib-amd/components/CommonComponents/CartesianChart.types.d.ts +12 -2
  69. package/lib-amd/components/CommonComponents/CartesianChart.types.js.map +1 -1
  70. package/lib-amd/components/DeclarativeChart/DeclarativeChart.js +37 -15
  71. package/lib-amd/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  72. package/lib-amd/components/DeclarativeChart/PlotlyColorAdapter.d.ts +2 -1
  73. package/lib-amd/components/DeclarativeChart/PlotlyColorAdapter.js +11 -2
  74. package/lib-amd/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
  75. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +13 -3
  76. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +276 -199
  77. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  78. package/lib-amd/components/DonutChart/DonutChart.base.js +1 -0
  79. package/lib-amd/components/DonutChart/DonutChart.base.js.map +1 -1
  80. package/lib-amd/components/DonutChart/DonutChart.styles.js +17 -1
  81. package/lib-amd/components/DonutChart/DonutChart.styles.js.map +1 -1
  82. package/lib-amd/components/DonutChart/DonutChart.types.d.ts +4 -0
  83. package/lib-amd/components/DonutChart/DonutChart.types.js.map +1 -1
  84. package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.d.ts +2 -0
  85. package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +24 -3
  86. package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
  87. package/lib-amd/components/HeatMapChart/HeatMapChart.base.d.ts +7 -0
  88. package/lib-amd/components/HeatMapChart/HeatMapChart.base.js +94 -36
  89. package/lib-amd/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
  90. package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.d.ts +3 -0
  91. package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +23 -2
  92. package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
  93. package/lib-amd/components/ScatterChart/ScatterChart.base.js +83 -54
  94. package/lib-amd/components/ScatterChart/ScatterChart.base.js.map +1 -1
  95. package/lib-amd/components/ScatterChart/ScatterChart.styles.js +12 -1
  96. package/lib-amd/components/ScatterChart/ScatterChart.styles.js.map +1 -1
  97. package/lib-amd/components/ScatterChart/ScatterChart.types.d.ts +5 -0
  98. package/lib-amd/components/ScatterChart/ScatterChart.types.js.map +1 -1
  99. package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.d.ts +2 -0
  100. package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js +29 -6
  101. package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
  102. package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.d.ts +3 -0
  103. package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +50 -31
  104. package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
  105. package/lib-amd/index.d.ts +1 -1
  106. package/lib-amd/index.js.map +1 -1
  107. package/lib-amd/types/IDataPoint.d.ts +18 -0
  108. package/lib-amd/types/IDataPoint.js.map +1 -1
  109. package/lib-amd/utilities/SVGTooltipText.js +3 -3
  110. package/lib-amd/utilities/SVGTooltipText.js.map +1 -1
  111. package/lib-amd/utilities/utilities.d.ts +6 -3
  112. package/lib-amd/utilities/utilities.js +59 -30
  113. package/lib-amd/utilities/utilities.js.map +1 -1
  114. package/lib-commonjs/components/AreaChart/AreaChart.base.d.ts +1 -0
  115. package/lib-commonjs/components/AreaChart/AreaChart.base.js +4 -1
  116. package/lib-commonjs/components/AreaChart/AreaChart.base.js.map +1 -1
  117. package/lib-commonjs/components/CommonComponents/CartesianChart.base.js +14 -13
  118. package/lib-commonjs/components/CommonComponents/CartesianChart.base.js.map +1 -1
  119. package/lib-commonjs/components/CommonComponents/CartesianChart.styles.js +41 -37
  120. package/lib-commonjs/components/CommonComponents/CartesianChart.styles.js.map +1 -1
  121. package/lib-commonjs/components/CommonComponents/CartesianChart.types.d.ts +12 -2
  122. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
  123. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +37 -15
  124. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  125. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.d.ts +2 -1
  126. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +11 -2
  127. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
  128. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +13 -3
  129. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +276 -198
  130. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  131. package/lib-commonjs/components/DonutChart/DonutChart.base.js +1 -0
  132. package/lib-commonjs/components/DonutChart/DonutChart.base.js.map +1 -1
  133. package/lib-commonjs/components/DonutChart/DonutChart.styles.js +18 -0
  134. package/lib-commonjs/components/DonutChart/DonutChart.styles.js.map +1 -1
  135. package/lib-commonjs/components/DonutChart/DonutChart.types.d.ts +4 -0
  136. package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -1
  137. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.d.ts +2 -0
  138. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +24 -3
  139. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
  140. package/lib-commonjs/components/HeatMapChart/HeatMapChart.base.d.ts +7 -0
  141. package/lib-commonjs/components/HeatMapChart/HeatMapChart.base.js +94 -36
  142. package/lib-commonjs/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
  143. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.d.ts +3 -0
  144. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +23 -2
  145. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
  146. package/lib-commonjs/components/ScatterChart/ScatterChart.base.js +83 -54
  147. package/lib-commonjs/components/ScatterChart/ScatterChart.base.js.map +1 -1
  148. package/lib-commonjs/components/ScatterChart/ScatterChart.styles.js +12 -0
  149. package/lib-commonjs/components/ScatterChart/ScatterChart.styles.js.map +1 -1
  150. package/lib-commonjs/components/ScatterChart/ScatterChart.types.d.ts +5 -0
  151. package/lib-commonjs/components/ScatterChart/ScatterChart.types.js.map +1 -1
  152. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.d.ts +2 -0
  153. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js +29 -6
  154. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
  155. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.d.ts +3 -0
  156. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +50 -31
  157. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
  158. package/lib-commonjs/index.d.ts +1 -1
  159. package/lib-commonjs/index.js.map +1 -1
  160. package/lib-commonjs/types/IDataPoint.d.ts +18 -0
  161. package/lib-commonjs/types/IDataPoint.js.map +1 -1
  162. package/lib-commonjs/utilities/SVGTooltipText.js +3 -3
  163. package/lib-commonjs/utilities/SVGTooltipText.js.map +1 -1
  164. package/lib-commonjs/utilities/utilities.d.ts +6 -3
  165. package/lib-commonjs/utilities/utilities.js +59 -30
  166. package/lib-commonjs/utilities/utilities.js.map +1 -1
  167. package/package.json +2 -2
  168. package/src/components/CommonComponents/CartesianChart.types.ts +20 -1
  169. package/src/components/DonutChart/DonutChart.types.ts +5 -0
  170. package/src/components/ScatterChart/ScatterChart.types.ts +7 -1
@@ -379,7 +379,9 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
379
379
  React.createElement("g", tslib_1.__assign({ id: "".concat(indexNumber, "-singleBar"), ref: function (e) { return (groupRef.refElement = e); } }, stackFocusProps), singleBar),
380
380
  !_this.props.hideLabels && _this._barWidth >= 16 && showLabel && (React.createElement("text", { x: xPoint + _this._barWidth / 2,
381
381
  //if total bar value >=0, show label above top bar, otherwise below bottom bar
382
- y: barLabel >= _this.Y_ORIGIN ? yPoint - 6 : yPoint + heightOfLastBar + 12, textAnchor: "middle", className: _this._classNames.barLabel, "aria-label": "Total: ".concat(barLabel), role: "img", transform: "translate(".concat(xScaleBandwidthTranslate, ", 0)") }, (0, index_3.formatScientificLimitWidth)(barLabel)))));
382
+ y: barLabel >= _this.Y_ORIGIN ? yPoint - 6 : yPoint + heightOfLastBar + 12, textAnchor: "middle", className: _this._classNames.barLabel, "aria-label": "Total: ".concat(barLabel), role: "img", transform: "translate(".concat(xScaleBandwidthTranslate, ", 0)") }, typeof _this.props.yAxisTickFormat === 'function'
383
+ ? _this.props.yAxisTickFormat(barLabel)
384
+ : (0, index_3.formatScientificLimitWidth)(barLabel)))));
383
385
  });
384
386
  // Removing un wanted tooltip div from DOM, when prop not provided.
385
387
  if (!_this.props.showXAxisLablesTooltip) {
@@ -594,33 +596,7 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
594
596
  }
595
597
  });
596
598
  }
597
- if (_this._yAxisType === index_3.YAxisType.StringAxis) {
598
- var legendToYValues_1 = {};
599
- _this._points.forEach(function (xPoint) {
600
- xPoint.chartData.forEach(function (bar) {
601
- if (!legendToYValues_1[bar.legend]) {
602
- legendToYValues_1[bar.legend] = ["".concat(bar.data)];
603
- }
604
- else {
605
- legendToYValues_1[bar.legend].push("".concat(bar.data));
606
- }
607
- });
608
- });
609
- var yAxisLabels_1 = new Set();
610
- Object.values(legendToYValues_1).forEach(function (yValues) {
611
- yValues.forEach(function (yVal) {
612
- yAxisLabels_1.add(yVal);
613
- });
614
- });
615
- Object.values(_this._lineObject).forEach(function (linePoints) {
616
- linePoints.forEach(function (linePoint) {
617
- if (!linePoint.useSecondaryYScale) {
618
- yAxisLabels_1.add("".concat(linePoint.y));
619
- }
620
- });
621
- });
622
- _this._yAxisLabels = Array.from(yAxisLabels_1);
623
- }
599
+ _this._yAxisLabels = _this._getOrderedYAxisLabels();
624
600
  };
625
601
  _this._getYDomainMargins = function (containerHeight) {
626
602
  /**
@@ -647,6 +623,49 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
647
623
  }
648
624
  return tslib_1.__assign(tslib_1.__assign({}, _this.margins), { top: _this.margins.top + yAxisTickMarginTop });
649
625
  };
626
+ _this._getOrderedXAxisLabels = function () {
627
+ if (_this._xAxisType !== index_3.XAxisTypes.StringAxis) {
628
+ return [];
629
+ }
630
+ return (0, index_3.sortAxisCategories)(_this._mapCategoryToValues(), _this.props.xAxisCategoryOrder);
631
+ };
632
+ _this._getOrderedYAxisLabels = function () {
633
+ if (_this._yAxisType !== index_3.YAxisType.StringAxis) {
634
+ return [];
635
+ }
636
+ return (0, index_3.sortAxisCategories)(_this._mapCategoryToValues(true), _this.props.yAxisCategoryOrder);
637
+ };
638
+ _this._mapCategoryToValues = function (isYAxis) {
639
+ if (isYAxis === void 0) { isYAxis = false; }
640
+ var categoryToValues = {};
641
+ _this._points.forEach(function (point) {
642
+ var _a;
643
+ point.chartData.forEach(function (bar) {
644
+ var category = (isYAxis ? bar.data : point.xAxisPoint);
645
+ var value = isYAxis ? point.xAxisPoint : bar.data;
646
+ if (!categoryToValues[category]) {
647
+ categoryToValues[category] = [];
648
+ }
649
+ if (typeof value === 'number') {
650
+ categoryToValues[category].push(value);
651
+ }
652
+ });
653
+ (_a = point.lineData) === null || _a === void 0 ? void 0 : _a.forEach(function (linePoint) {
654
+ if (isYAxis && linePoint.useSecondaryYScale) {
655
+ return;
656
+ }
657
+ var category = (isYAxis ? linePoint.y : point.xAxisPoint);
658
+ var value = isYAxis ? point.xAxisPoint : linePoint.y;
659
+ if (!categoryToValues[category]) {
660
+ categoryToValues[category] = [];
661
+ }
662
+ if (typeof value === 'number') {
663
+ categoryToValues[category].push(value);
664
+ }
665
+ });
666
+ });
667
+ return categoryToValues;
668
+ };
650
669
  (0, Utilities_1.initializeComponentRef)(_this);
651
670
  _this.state = {
652
671
  isCalloutVisible: false,
@@ -749,9 +768,7 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
749
768
  };
750
769
  VerticalStackedBarChartBase.prototype._createDataSetLayer = function () {
751
770
  var _this = this;
752
- var tempArr = [];
753
771
  var dataset = this._points.map(function (singlePointData) {
754
- tempArr.push(singlePointData.xAxisPoint);
755
772
  if (_this._yAxisType === index_3.YAxisType.StringAxis) {
756
773
  return {
757
774
  x: singlePointData.xAxisPoint,
@@ -767,7 +784,7 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
767
784
  y: total,
768
785
  };
769
786
  });
770
- this._xAxisLabels = tempArr;
787
+ this._xAxisLabels = this._getOrderedXAxisLabels();
771
788
  return dataset;
772
789
  };
773
790
  VerticalStackedBarChartBase.prototype._renderCallout = function (props) {
@@ -979,6 +996,8 @@ define(["require", "exports", "tslib", "react", "d3-array", "d3-selection", "d3-
979
996
  VerticalStackedBarChartBase.defaultProps = {
980
997
  maxBarWidth: 24,
981
998
  useUTC: true,
999
+ xAxisCategoryOrder: 'default',
1000
+ yAxisCategoryOrder: 'default',
982
1001
  };
983
1002
  return VerticalStackedBarChartBase;
984
1003
  }(React.Component));