@fluentui/react-charting 5.23.97 → 5.24.0

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 (156) hide show
  1. package/CHANGELOG.json +36 -1
  2. package/CHANGELOG.md +17 -2
  3. package/dist/react-charting.d.ts +16 -7
  4. package/dist/react-charting.js +1 -1
  5. package/dist/react-charting.min.js +1 -1
  6. package/etc/react-charting.api.md +9 -7
  7. package/lib/components/AreaChart/AreaChart.base.js +7 -4
  8. package/lib/components/AreaChart/AreaChart.base.js.map +1 -1
  9. package/lib/components/CommonComponents/CartesianChart.base.d.ts +1 -2
  10. package/lib/components/CommonComponents/CartesianChart.base.js +31 -27
  11. package/lib/components/CommonComponents/CartesianChart.base.js.map +1 -1
  12. package/lib/components/CommonComponents/CartesianChart.types.d.ts +2 -2
  13. package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
  14. package/lib/components/DeclarativeChart/DeclarativeChart.js +3 -2
  15. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  16. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +1 -0
  17. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +10 -8
  18. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  19. package/lib/components/DonutChart/Arc/Arc.js +2 -2
  20. package/lib/components/DonutChart/Arc/Arc.js.map +1 -1
  21. package/lib/components/DonutChart/DonutChart.base.js +6 -4
  22. package/lib/components/DonutChart/DonutChart.base.js.map +1 -1
  23. package/lib/components/GaugeChart/GaugeChart.base.js +9 -9
  24. package/lib/components/GaugeChart/GaugeChart.base.js.map +1 -1
  25. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +2 -2
  26. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
  27. package/lib/components/HeatMapChart/HeatMapChart.base.js +2 -2
  28. package/lib/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
  29. package/lib/components/HorizontalBarChart/HorizontalBarChart.base.js +7 -7
  30. package/lib/components/HorizontalBarChart/HorizontalBarChart.base.js.map +1 -1
  31. package/lib/components/LineChart/LineChart.base.js +8 -5
  32. package/lib/components/LineChart/LineChart.base.js.map +1 -1
  33. package/lib/components/PieChart/Arc/Arc.js +3 -3
  34. package/lib/components/PieChart/Arc/Arc.js.map +1 -1
  35. package/lib/components/StackedBarChart/MultiStackedBarChart.base.js +5 -5
  36. package/lib/components/StackedBarChart/MultiStackedBarChart.base.js.map +1 -1
  37. package/lib/components/StackedBarChart/StackedBarChart.base.js +3 -5
  38. package/lib/components/StackedBarChart/StackedBarChart.base.js.map +1 -1
  39. package/lib/components/VerticalBarChart/VerticalBarChart.base.js +16 -7
  40. package/lib/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
  41. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.d.ts +4 -0
  42. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +155 -40
  43. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
  44. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.d.ts +9 -0
  45. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
  46. package/lib/types/IDataPoint.d.ts +5 -5
  47. package/lib/types/IDataPoint.js.map +1 -1
  48. package/lib/utilities/ChartHoverCard/ChartHoverCard.base.js +5 -5
  49. package/lib/utilities/ChartHoverCard/ChartHoverCard.base.js.map +1 -1
  50. package/lib/utilities/utilities.d.ts +3 -6
  51. package/lib/utilities/utilities.js +22 -49
  52. package/lib/utilities/utilities.js.map +1 -1
  53. package/lib-amd/components/AreaChart/AreaChart.base.js +6 -4
  54. package/lib-amd/components/AreaChart/AreaChart.base.js.map +1 -1
  55. package/lib-amd/components/CommonComponents/CartesianChart.base.d.ts +1 -2
  56. package/lib-amd/components/CommonComponents/CartesianChart.base.js +31 -27
  57. package/lib-amd/components/CommonComponents/CartesianChart.base.js.map +1 -1
  58. package/lib-amd/components/CommonComponents/CartesianChart.types.d.ts +2 -2
  59. package/lib-amd/components/CommonComponents/CartesianChart.types.js.map +1 -1
  60. package/lib-amd/components/DeclarativeChart/DeclarativeChart.js +2 -1
  61. package/lib-amd/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  62. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +1 -0
  63. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +15 -12
  64. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  65. package/lib-amd/components/DonutChart/Arc/Arc.js +1 -1
  66. package/lib-amd/components/DonutChart/Arc/Arc.js.map +1 -1
  67. package/lib-amd/components/DonutChart/DonutChart.base.js +5 -3
  68. package/lib-amd/components/DonutChart/DonutChart.base.js.map +1 -1
  69. package/lib-amd/components/GaugeChart/GaugeChart.base.js +8 -8
  70. package/lib-amd/components/GaugeChart/GaugeChart.base.js.map +1 -1
  71. package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +1 -1
  72. package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
  73. package/lib-amd/components/HeatMapChart/HeatMapChart.base.js +2 -2
  74. package/lib-amd/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
  75. package/lib-amd/components/HorizontalBarChart/HorizontalBarChart.base.js +6 -6
  76. package/lib-amd/components/HorizontalBarChart/HorizontalBarChart.base.js.map +1 -1
  77. package/lib-amd/components/LineChart/LineChart.base.js +7 -5
  78. package/lib-amd/components/LineChart/LineChart.base.js.map +1 -1
  79. package/lib-amd/components/PieChart/Arc/Arc.js +3 -3
  80. package/lib-amd/components/PieChart/Arc/Arc.js.map +1 -1
  81. package/lib-amd/components/StackedBarChart/MultiStackedBarChart.base.js +4 -4
  82. package/lib-amd/components/StackedBarChart/MultiStackedBarChart.base.js.map +1 -1
  83. package/lib-amd/components/StackedBarChart/StackedBarChart.base.js +3 -5
  84. package/lib-amd/components/StackedBarChart/StackedBarChart.base.js.map +1 -1
  85. package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js +15 -7
  86. package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
  87. package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.d.ts +4 -0
  88. package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +154 -40
  89. package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
  90. package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.types.d.ts +9 -0
  91. package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
  92. package/lib-amd/types/IDataPoint.d.ts +5 -5
  93. package/lib-amd/types/IDataPoint.js.map +1 -1
  94. package/lib-amd/utilities/ChartHoverCard/ChartHoverCard.base.js +5 -5
  95. package/lib-amd/utilities/ChartHoverCard/ChartHoverCard.base.js.map +1 -1
  96. package/lib-amd/utilities/utilities.d.ts +3 -6
  97. package/lib-amd/utilities/utilities.js +25 -55
  98. package/lib-amd/utilities/utilities.js.map +1 -1
  99. package/lib-commonjs/components/AreaChart/AreaChart.base.js +6 -3
  100. package/lib-commonjs/components/AreaChart/AreaChart.base.js.map +1 -1
  101. package/lib-commonjs/components/CommonComponents/CartesianChart.base.d.ts +1 -2
  102. package/lib-commonjs/components/CommonComponents/CartesianChart.base.js +31 -27
  103. package/lib-commonjs/components/CommonComponents/CartesianChart.base.js.map +1 -1
  104. package/lib-commonjs/components/CommonComponents/CartesianChart.types.d.ts +2 -2
  105. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
  106. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +2 -1
  107. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  108. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +1 -0
  109. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +15 -12
  110. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  111. package/lib-commonjs/components/DonutChart/Arc/Arc.js +1 -1
  112. package/lib-commonjs/components/DonutChart/Arc/Arc.js.map +1 -1
  113. package/lib-commonjs/components/DonutChart/DonutChart.base.js +5 -3
  114. package/lib-commonjs/components/DonutChart/DonutChart.base.js.map +1 -1
  115. package/lib-commonjs/components/GaugeChart/GaugeChart.base.js +8 -8
  116. package/lib-commonjs/components/GaugeChart/GaugeChart.base.js.map +1 -1
  117. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +1 -1
  118. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
  119. package/lib-commonjs/components/HeatMapChart/HeatMapChart.base.js +2 -2
  120. package/lib-commonjs/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
  121. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.base.js +6 -6
  122. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.base.js.map +1 -1
  123. package/lib-commonjs/components/LineChart/LineChart.base.js +7 -4
  124. package/lib-commonjs/components/LineChart/LineChart.base.js.map +1 -1
  125. package/lib-commonjs/components/PieChart/Arc/Arc.js +3 -3
  126. package/lib-commonjs/components/PieChart/Arc/Arc.js.map +1 -1
  127. package/lib-commonjs/components/StackedBarChart/MultiStackedBarChart.base.js +4 -4
  128. package/lib-commonjs/components/StackedBarChart/MultiStackedBarChart.base.js.map +1 -1
  129. package/lib-commonjs/components/StackedBarChart/StackedBarChart.base.js +3 -5
  130. package/lib-commonjs/components/StackedBarChart/StackedBarChart.base.js.map +1 -1
  131. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js +15 -6
  132. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
  133. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.d.ts +4 -0
  134. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +154 -39
  135. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
  136. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.d.ts +9 -0
  137. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
  138. package/lib-commonjs/types/IDataPoint.d.ts +5 -5
  139. package/lib-commonjs/types/IDataPoint.js.map +1 -1
  140. package/lib-commonjs/utilities/ChartHoverCard/ChartHoverCard.base.js +5 -5
  141. package/lib-commonjs/utilities/ChartHoverCard/ChartHoverCard.base.js.map +1 -1
  142. package/lib-commonjs/utilities/utilities.d.ts +3 -6
  143. package/lib-commonjs/utilities/utilities.js +26 -55
  144. package/lib-commonjs/utilities/utilities.js.map +1 -1
  145. package/package.json +2 -2
  146. package/src/components/CommonComponents/CartesianChart.types.ts +2 -1
  147. package/src/components/VerticalStackedBarChart/VerticalStackedBarChart.types.ts +11 -0
  148. package/lib/utilities/locale-util.d.ts +0 -3
  149. package/lib/utilities/locale-util.js +0 -18
  150. package/lib/utilities/locale-util.js.map +0 -1
  151. package/lib-amd/utilities/locale-util.d.ts +0 -3
  152. package/lib-amd/utilities/locale-util.js +0 -24
  153. package/lib-amd/utilities/locale-util.js.map +0 -1
  154. package/lib-commonjs/utilities/locale-util.d.ts +0 -3
  155. package/lib-commonjs/utilities/locale-util.js +0 -22
  156. package/lib-commonjs/utilities/locale-util.js.map +0 -1
@@ -11,6 +11,7 @@ var Callout_1 = require("@fluentui/react/lib/Callout");
11
11
  var index_1 = require("../Legends/index");
12
12
  var index_2 = require("../../index");
13
13
  var react_focus_1 = require("@fluentui/react-focus");
14
+ var chart_utilities_1 = require("@fluentui/chart-utilities");
14
15
  var index_3 = require("../../utilities/index");
15
16
  var image_export_utils_1 = require("../../utilities/image-export-utils");
16
17
  var getClassNames = (0, Utilities_1.classNamesFunction)();
@@ -28,6 +29,7 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
28
29
  var _this = _super.call(this, props) || this;
29
30
  _this._isRtl = (0, Utilities_1.getRTL)();
30
31
  _this.Y_ORIGIN = 0;
32
+ _this._yAxisLabels = [];
31
33
  _this.toImage = function (opts) {
32
34
  var _a, _b;
33
35
  return (0, image_export_utils_1.toImage)((_a = _this._cartesianChartRef.current) === null || _a === void 0 ? void 0 : _a.chartContainer, (_b = _this._legendsRef.current) === null || _b === void 0 ? void 0 : _b.toSVG, _this._isRtl, opts);
@@ -124,13 +126,20 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
124
126
  var useSecondaryYScale = lineObject[item][i - 1].useSecondaryYScale && lineObject[item][i].useSecondaryYScale && yScaleSecondary;
125
127
  var y1 = useSecondaryYScale
126
128
  ? yScaleSecondary(lineObject[item][i - 1].y)
127
- : yScalePrimary(lineObject[item][i - 1].y);
129
+ : //eslint-disable-next-line @typescript-eslint/no-explicit-any
130
+ yScalePrimary(lineObject[item][i - 1].y);
128
131
  var x2 = xScale(lineObject[item][i].xItem.xAxisPoint);
129
- var y2 = useSecondaryYScale ? yScaleSecondary(lineObject[item][i].y) : yScalePrimary(lineObject[item][i].y);
132
+ var y2 = useSecondaryYScale
133
+ ? yScaleSecondary(lineObject[item][i].y)
134
+ : //eslint-disable-next-line @typescript-eslint/no-explicit-any
135
+ yScalePrimary(lineObject[item][i].y);
136
+ var yScaleBandwidthTranslate = !useSecondaryYScale && _this._yAxisType === index_3.YAxisType.StringAxis
137
+ ? yScalePrimary.bandwidth() / 2
138
+ : 0;
130
139
  if (lineBorderWidth > 0) {
131
- borderForLines.push(React.createElement("line", { key: "".concat(index, "-").concat(i, "-BorderLine"), x1: x1, y1: y1, x2: x2, y2: y2, opacity: shouldHighlight ? 1 : 0.1, strokeWidth: 3 + lineBorderWidth * 2, fill: "transparent", strokeLinecap: "round", stroke: theme.semanticColors.bodyBackground, transform: "translate(".concat(xScaleBandwidthTranslate, ", 0)") }));
140
+ borderForLines.push(React.createElement("line", { key: "".concat(index, "-").concat(i, "-BorderLine"), x1: x1, y1: y1, x2: x2, y2: y2, opacity: shouldHighlight ? 1 : 0.1, strokeWidth: 3 + lineBorderWidth * 2, fill: "transparent", strokeLinecap: "round", stroke: theme.semanticColors.bodyBackground, transform: "translate(".concat(xScaleBandwidthTranslate, ", ").concat(yScaleBandwidthTranslate, ")") }));
132
141
  }
133
- lines.push(React.createElement("line", { key: "".concat(index, "-").concat(i, "-line"), x1: x1, y1: y1, x2: x2, y2: y2, opacity: shouldHighlight ? 1 : 0.1, strokeWidth: (_b = (_a = lineObject[item][0].lineOptions) === null || _a === void 0 ? void 0 : _a.strokeWidth) !== null && _b !== void 0 ? _b : 3, strokeLinecap: (_d = (_c = lineObject[item][0].lineOptions) === null || _c === void 0 ? void 0 : _c.strokeLinecap) !== null && _d !== void 0 ? _d : 'round', strokeDasharray: (_e = lineObject[item][0].lineOptions) === null || _e === void 0 ? void 0 : _e.strokeDasharray, stroke: lineObject[item][i].color, transform: "translate(".concat(xScaleBandwidthTranslate, ", 0)"), onMouseOver: _this._lineHover.bind(_this, lineObject[item][i - 1]), onMouseLeave: _this._handleMouseOut }));
142
+ lines.push(React.createElement("line", { key: "".concat(index, "-").concat(i, "-line"), x1: x1, y1: y1, x2: x2, y2: y2, opacity: shouldHighlight ? 1 : 0.1, strokeWidth: (_b = (_a = lineObject[item][0].lineOptions) === null || _a === void 0 ? void 0 : _a.strokeWidth) !== null && _b !== void 0 ? _b : 3, strokeLinecap: (_d = (_c = lineObject[item][0].lineOptions) === null || _c === void 0 ? void 0 : _c.strokeLinecap) !== null && _d !== void 0 ? _d : 'round', strokeDasharray: (_e = lineObject[item][0].lineOptions) === null || _e === void 0 ? void 0 : _e.strokeDasharray, stroke: lineObject[item][i].color, transform: "translate(".concat(xScaleBandwidthTranslate, ", ").concat(yScaleBandwidthTranslate, ")"), onMouseOver: _this._lineHover.bind(_this, lineObject[item][i - 1]), onMouseLeave: _this._handleMouseOut }));
134
143
  }
135
144
  });
136
145
  Object.keys(lineObject).forEach(function (item, index) {
@@ -138,12 +147,16 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
138
147
  // Create an object to store line point ref so that the object can be passed by reference to the focus handler
139
148
  var circleRef = { refElement: null };
140
149
  var noBarsActive = circlePoint.xItem.chartData.filter(function (dataPoint) { return _this._noLegendHighlighted() || _this._isLegendHighlighted(dataPoint.legend); }).length === 0;
150
+ var yScaleBandwidthTranslate = !circlePoint.useSecondaryYScale && _this._yAxisType === index_3.YAxisType.StringAxis
151
+ ? yScalePrimary.bandwidth() / 2
152
+ : 0;
141
153
  dots.push(React.createElement("circle", tslib_1.__assign({ key: "".concat(index, "-").concat(subIndex, "-dot"), cx: xScale(circlePoint.xItem.xAxisPoint), cy: circlePoint.useSecondaryYScale && yScaleSecondary
142
154
  ? yScaleSecondary(circlePoint.y)
143
- : yScalePrimary(circlePoint.y), onMouseOver: _this._lineHover.bind(_this, circlePoint), onMouseLeave: _this._handleMouseOut, r: _this._getCircleOpacityAndRadius(circlePoint.xItem.xAxisPoint, circlePoint.legend).radius, stroke: circlePoint.color, fill: _this.props.theme.semanticColors.bodyBackground, strokeWidth: 3,
155
+ : // eslint-disable-next-line @typescript-eslint/no-explicit-any
156
+ yScalePrimary(circlePoint.y), onMouseOver: _this._lineHover.bind(_this, circlePoint), onMouseLeave: _this._handleMouseOut, r: _this._getCircleOpacityAndRadius(circlePoint.xItem.xAxisPoint, circlePoint.legend).radius, stroke: circlePoint.color, fill: _this.props.theme.semanticColors.bodyBackground, strokeWidth: 3,
144
157
  // Elements with visibility: hidden cannot receive focus, so use opacity: 0 instead to hide them.
145
158
  // For more information, see https://fuzzbomb.github.io/accessibility-demos/visually-hidden-focus-test.html
146
- opacity: _this._getCircleOpacityAndRadius(circlePoint.xItem.xAxisPoint, circlePoint.legend).opacity, transform: "translate(".concat(xScaleBandwidthTranslate, ", 0)"), ref: function (e) { return (circleRef.refElement = e); } }, (noBarsActive && (_this._noLegendHighlighted() || _this._isLegendHighlighted(item))
159
+ opacity: _this._getCircleOpacityAndRadius(circlePoint.xItem.xAxisPoint, circlePoint.legend).opacity, transform: "translate(".concat(xScaleBandwidthTranslate, ", ").concat(yScaleBandwidthTranslate, ")"), ref: function (e) { return (circleRef.refElement = e); } }, (noBarsActive && (_this._noLegendHighlighted() || _this._isLegendHighlighted(item))
147
160
  ? {
148
161
  'data-is-focusable': !_this.props.hideTooltip,
149
162
  onFocus: _this._lineFocus.bind(_this, circlePoint, circleRef),
@@ -246,7 +259,12 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
246
259
  var xScaleBandwidthTranslate = _this._xAxisType !== index_3.XAxisTypes.StringAxis ? -_this._barWidth / 2 : (xBarScale.bandwidth() - _this._barWidth) / 2;
247
260
  var barTotalValue = 0;
248
261
  // Removing datapoints with zero data
249
- var barsToDisplay = singleChartData.chartData.filter(function (point) { return point.data !== 0; });
262
+ var barsToDisplay = singleChartData.chartData.filter(function (point) {
263
+ return point.data !== 0 &&
264
+ point.data !== '' &&
265
+ !(_this._yAxisType === index_3.YAxisType.StringAxis &&
266
+ typeof yBarScale(point.data) === 'undefined');
267
+ });
250
268
  if (!barsToDisplay.length) {
251
269
  return undefined;
252
270
  }
@@ -254,7 +272,9 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
254
272
  if (heightValueScale < 0) {
255
273
  return undefined;
256
274
  }
257
- var yBaseline = containerHeight - _this.margins.bottom - yBarScale(_this.Y_ORIGIN);
275
+ var yBaseline = containerHeight -
276
+ _this.margins.bottom -
277
+ (_this._yAxisType === index_3.YAxisType.StringAxis ? 0 : yBarScale(_this.Y_ORIGIN));
258
278
  var yPositiveStart = yBaseline;
259
279
  var yNegativeStart = yBaseline;
260
280
  var yPoint = 0;
@@ -287,22 +307,33 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
287
307
  onClick: _this._onClick.bind(_this, point),
288
308
  role: 'img',
289
309
  };
290
- var barHeight = Math.abs(heightValueScale * point.data);
291
- var minHeight = Math.max((heightValueScale * adjustedTotalHeight) / 100.0, barMinimumHeight);
292
- if (barHeight < minHeight) {
293
- barHeight = minHeight;
294
- }
310
+ var barHeight;
295
311
  var gapOffset = index ? gapHeight : 0;
296
- if (point.data >= _this.Y_ORIGIN) {
312
+ if (_this._yAxisType === index_3.YAxisType.StringAxis) {
313
+ barHeight = Math.max(containerHeight -
314
+ _this.margins.bottom -
315
+ (yBarScale(point.data) + yBarScale.bandwidth() / 2) -
316
+ gapOffset, barMinimumHeight, 1);
297
317
  yPositiveStart -= barHeight + gapOffset;
298
318
  yPoint = yPositiveStart;
299
319
  }
300
320
  else {
301
- yPoint = yNegativeStart + gapOffset;
302
- yNegativeStart = yPoint + barHeight;
321
+ barHeight = Math.abs(heightValueScale * point.data);
322
+ var minHeight = Math.max((heightValueScale * adjustedTotalHeight) / 100.0, barMinimumHeight);
323
+ if (barHeight < minHeight) {
324
+ barHeight = minHeight;
325
+ }
326
+ if (point.data >= _this.Y_ORIGIN) {
327
+ yPositiveStart -= barHeight + gapOffset;
328
+ yPoint = yPositiveStart;
329
+ }
330
+ else {
331
+ yPoint = yNegativeStart + gapOffset;
332
+ yNegativeStart = yPoint + barHeight;
333
+ }
334
+ barTotalValue += point.data;
335
+ heightOfLastBar = index === barsToDisplay.length - 1 ? barHeight : 0;
303
336
  }
304
- barTotalValue += point.data;
305
- heightOfLastBar = index === barsToDisplay.length - 1 ? barHeight : 0;
306
337
  var gradientId = (0, Utilities_1.getId)('VSBC_Gradient') + "_".concat(indexNumber, "_").concat(index);
307
338
  // If set, apply the corner radius to the top of the final bar
308
339
  if (barCornerRadius && barHeight > barCornerRadius && index === barsToDisplay.length - 1) {
@@ -342,7 +373,7 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
342
373
  };
343
374
  var showLabel = false;
344
375
  var barLabel = 0;
345
- if (!_this.props.hideLabels) {
376
+ if (!_this.props.hideLabels && _this._yAxisType !== index_3.YAxisType.StringAxis) {
346
377
  if (_this._noLegendHighlighted()) {
347
378
  showLabel = true;
348
379
  barLabel = barTotalValue;
@@ -360,7 +391,7 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
360
391
  React.createElement("g", tslib_1.__assign({ id: "".concat(indexNumber, "-singleBar"), ref: function (e) { return (groupRef.refElement = e); } }, stackFocusProps), singleBar),
361
392
  !_this.props.hideLabels && _this._barWidth >= 16 && showLabel && (React.createElement("text", { x: xPoint + _this._barWidth / 2,
362
393
  //if total bar value >=0, show label above top bar, otherwise below bottom bar
363
- 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.formatValueLimitWidth)(barLabel)))));
394
+ 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)))));
364
395
  });
365
396
  // Removing un wanted tooltip div from DOM, when prop not provided.
366
397
  if (!_this.props.showXAxisLablesTooltip) {
@@ -429,7 +460,7 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
429
460
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
430
461
  xScale, yScale, containerHeight, containerWidth, xElement) {
431
462
  var _a = _this._getScales(containerHeight, containerWidth), xBarScale = _a.xBarScale, yBarScale = _a.yBarScale;
432
- return (_this._bars = _this._createBar(xBarScale, yBarScale, containerHeight, xElement));
463
+ return (_this._bars = _this._createBar(xBarScale, _this._yAxisType === index_3.YAxisType.StringAxis ? yScale : yBarScale, containerHeight, xElement));
433
464
  };
434
465
  _this._closeCallout = function () {
435
466
  _this.setState({
@@ -464,7 +495,7 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
464
495
  /** if shouldFocusWholeStack is true */
465
496
  var xValue_1 = singleChartData.xAxisCalloutData ||
466
497
  (singleChartData.xAxisPoint instanceof Date
467
- ? (0, index_3.formatDate)(singleChartData.xAxisPoint)
498
+ ? (0, chart_utilities_1.formatDateToLocaleString)(singleChartData.xAxisPoint, _this.props.culture, _this.props.useUTC)
468
499
  : singleChartData.xAxisPoint);
469
500
  var pointValues = singleChartData.chartData
470
501
  .map(function (pt) {
@@ -486,7 +517,7 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
486
517
  var xValue = singleChartData.xAxisCalloutData ||
487
518
  (!isLinePoint && point.xAxisCalloutData) ||
488
519
  (singleChartData.xAxisPoint instanceof Date
489
- ? (0, index_3.formatDate)(singleChartData.xAxisPoint)
520
+ ? (0, chart_utilities_1.formatDateToLocaleString)(singleChartData.xAxisPoint, _this.props.culture, _this.props.useUTC)
490
521
  : singleChartData.xAxisPoint);
491
522
  var legend = point.legend;
492
523
  var yValue = point.yAxisCalloutData ||
@@ -564,6 +595,70 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
564
595
  });
565
596
  return { startValue: (0, d3_array_1.min)(values), endValue: (0, d3_array_1.max)(values) };
566
597
  };
598
+ _this._initYAxisParams = function () {
599
+ if (_this._points[0].chartData.length > 0) {
600
+ _this._yAxisType = (0, index_3.getTypeOfAxis)(_this._points[0].chartData[0].data, false);
601
+ }
602
+ else {
603
+ Object.keys(_this._lineObject).forEach(function (lineLegend) {
604
+ if (!_this._lineObject[lineLegend][0].useSecondaryYScale) {
605
+ _this._yAxisType = (0, index_3.getTypeOfAxis)(_this._lineObject[lineLegend][0].y, false);
606
+ }
607
+ });
608
+ }
609
+ if (_this._yAxisType === index_3.YAxisType.StringAxis) {
610
+ var legendToYValues_1 = {};
611
+ _this._points.forEach(function (xPoint) {
612
+ xPoint.chartData.forEach(function (bar) {
613
+ if (!legendToYValues_1[bar.legend]) {
614
+ legendToYValues_1[bar.legend] = ["".concat(bar.data)];
615
+ }
616
+ else {
617
+ legendToYValues_1[bar.legend].push("".concat(bar.data));
618
+ }
619
+ });
620
+ });
621
+ var yAxisLabels_1 = new Set();
622
+ Object.values(legendToYValues_1).forEach(function (yValues) {
623
+ yValues.forEach(function (yVal) {
624
+ yAxisLabels_1.add(yVal);
625
+ });
626
+ });
627
+ Object.values(_this._lineObject).forEach(function (linePoints) {
628
+ linePoints.forEach(function (linePoint) {
629
+ if (!linePoint.useSecondaryYScale) {
630
+ yAxisLabels_1.add("".concat(linePoint.y));
631
+ }
632
+ });
633
+ });
634
+ _this._yAxisLabels = Array.from(yAxisLabels_1);
635
+ }
636
+ };
637
+ _this._getYDomainMargins = function (containerHeight) {
638
+ /**
639
+ * Specifies the extra top margin to apply above the highest y-axis tick label.
640
+ * Useful when stacked bars extend beyond the combined height of all y-axis labels (or categories).
641
+ */
642
+ var yAxisTickMarginTop = 0;
643
+ /** Total height available to render the bars */
644
+ var totalHeight = containerHeight - _this.margins.bottom - _this.margins.top;
645
+ if (_this._yAxisType === index_3.YAxisType.StringAxis) {
646
+ /** Maximum height of the stacked bars, expressed in multiples of the height of a y-axis label (or category) */
647
+ var maxBarHeightInLabels_1 = 0;
648
+ _this._points.forEach(function (xPoint) {
649
+ /** Height of the stacked bar, expressed in multiples of the height of a y-axis label (or category) */
650
+ var barHeightInLabels = 0;
651
+ xPoint.chartData.forEach(function (bar) {
652
+ barHeightInLabels += _this._yAxisLabels.indexOf("".concat(bar.data)) + 1;
653
+ });
654
+ maxBarHeightInLabels_1 = Math.max(maxBarHeightInLabels_1, barHeightInLabels);
655
+ });
656
+ /** Height of a y-axis label (or category) */
657
+ var yAxisLabelHeight = maxBarHeightInLabels_1 === 0 ? 0 : totalHeight / maxBarHeightInLabels_1;
658
+ yAxisTickMarginTop += yAxisLabelHeight * (maxBarHeightInLabels_1 - _this._yAxisLabels.length);
659
+ }
660
+ return tslib_1.__assign(tslib_1.__assign({}, _this.margins), { top: _this.margins.top + yAxisTickMarginTop });
661
+ };
567
662
  (0, Utilities_1.initializeComponentRef)(_this);
568
663
  _this.state = {
569
664
  isCalloutVisible: false,
@@ -632,7 +727,7 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
632
727
  return (React.createElement(index_2.CartesianChart, tslib_1.__assign({}, this.props, { chartTitle: this._getChartTitle(), points: this._dataset, chartType: index_3.ChartTypes.VerticalStackedBarChart, xAxisType: this._xAxisType, calloutProps: calloutProps, createYAxis: index_3.createNumericYAxis, tickParams: tickParams, legendBars: legendBars, getMinMaxOfYAxis: this._getMinMaxOfYAxis, datasetForXAxisDomain: this._xAxisLabels, isCalloutForStack: shouldFocusWholeStack, getDomainNRangeValues: this._getDomainNRangeValues, createStringYAxis: index_3.createStringYAxis, barwidth: this._barWidth, focusZoneDirection: isCalloutForStack || _isHavingLines_1 ? react_focus_1.FocusZoneDirection.horizontal : react_focus_1.FocusZoneDirection.vertical, getmargins: this._getMargins, getGraphData: this._getGraphData, getAxisData: this._getAxisData, customizedCallout: this._getCustomizedCallout(), onChartMouseLeave: this._handleChartMouseLeave, getDomainMargins: this._getDomainMargins }, (this._xAxisType === index_3.XAxisTypes.StringAxis && {
633
728
  xAxisInnerPadding: this._xAxisInnerPadding,
634
729
  xAxisOuterPadding: this._xAxisOuterPadding,
635
- }), { ref: this._cartesianChartRef, showRoundOffXTickValues: !(0, index_3.isScalePaddingDefined)(this.props.xAxisInnerPadding, this.props.xAxisPadding),
730
+ }), { ref: this._cartesianChartRef, showRoundOffXTickValues: !(0, index_3.isScalePaddingDefined)(this.props.xAxisInnerPadding, this.props.xAxisPadding), yAxisType: this._yAxisType, stringDatasetForYAxisDomain: tslib_1.__spreadArray([''], this._yAxisLabels, true), getYDomainMargins: this._getYDomainMargins,
636
731
  /* eslint-disable react/jsx-no-bind */
637
732
  children: function (props) {
638
733
  return (React.createElement(React.Fragment, null,
@@ -662,15 +757,23 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
662
757
  this._lineObject = this._getFormattedLineData(this.props.data);
663
758
  this._xAxisInnerPadding = (0, index_3.getScalePadding)(this.props.xAxisInnerPadding, this.props.xAxisPadding, this._xAxisType === index_3.XAxisTypes.StringAxis ? 2 / 3 : 1 / 2);
664
759
  this._xAxisOuterPadding = (0, index_3.getScalePadding)(this.props.xAxisOuterPadding, this.props.xAxisPadding, 0);
760
+ this._initYAxisParams();
665
761
  };
666
762
  VerticalStackedBarChartBase.prototype._createDataSetLayer = function () {
763
+ var _this = this;
667
764
  var tempArr = [];
668
765
  var dataset = this._points.map(function (singlePointData) {
766
+ tempArr.push(singlePointData.xAxisPoint);
767
+ if (_this._yAxisType === index_3.YAxisType.StringAxis) {
768
+ return {
769
+ x: singlePointData.xAxisPoint,
770
+ y: 0,
771
+ };
772
+ }
669
773
  var total = 0;
670
774
  singlePointData.chartData.forEach(function (point) {
671
775
  total = total + point.data;
672
776
  });
673
- tempArr.push(singlePointData.xAxisPoint);
674
777
  return {
675
778
  x: singlePointData.xAxisPoint,
676
779
  y: total,
@@ -817,7 +920,9 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
817
920
  isCalloutVisible: stack.chartData.length > 0 || ((_c = (_b = stack.lineData) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0) > 0,
818
921
  YValueHover: isLinesPresent
819
922
  ? tslib_1.__spreadArray(tslib_1.__spreadArray([], lineData.sort(function (a, b) { return (a.data < b.data ? 1 : -1); }), true), stack.chartData.slice().reverse(), true) : stack.chartData.slice().reverse(),
820
- hoverXValue: stack.xAxisPoint instanceof Date ? (0, index_3.formatDate)(stack.xAxisPoint, this.props.useUTC) : stack.xAxisPoint,
923
+ hoverXValue: stack.xAxisPoint instanceof Date
924
+ ? (0, chart_utilities_1.formatDateToLocaleString)(stack.xAxisPoint, this.props.culture, this.props.useUTC)
925
+ : stack.xAxisPoint,
821
926
  stackCalloutProps: stack,
822
927
  activeXAxisDataPoint: stack.xAxisPoint,
823
928
  callOutAccessibilityData: stack.stackCallOutAccessibilityData,
@@ -840,22 +945,32 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
840
945
  };
841
946
  VerticalStackedBarChartBase.prototype._getBarGapAndScale = function (bars, yBarScale, defaultTotalHeight) {
842
947
  var _a = this.props.barGapMax, barGapMax = _a === void 0 ? 0 : _a;
843
- // When displaying gaps between the bars, the height of each bar is
844
- // adjusted so that the total of all bars is not changed by the gaps
845
- var totalData = bars.reduce(function (iter, value) { return iter + Math.abs(value.data); }, 0);
846
- var totalHeight = defaultTotalHeight !== null && defaultTotalHeight !== void 0 ? defaultTotalHeight : Math.abs(yBarScale(totalData) - yBarScale(this.Y_ORIGIN));
948
+ var totalData = 0;
949
+ var totalHeight;
847
950
  var sumOfPercent = 0;
848
- bars.forEach(function (point) {
849
- var value = (Math.abs(point.data) / totalData) * 100;
850
- if (value < 1 && value !== 0) {
851
- value = 1;
852
- }
853
- sumOfPercent += value;
854
- });
855
- var scalingRatio = sumOfPercent !== 0 ? sumOfPercent / 100 : 1;
951
+ var scalingRatio;
952
+ if (this._yAxisType === index_3.YAxisType.StringAxis) {
953
+ totalHeight =
954
+ defaultTotalHeight !== null && defaultTotalHeight !== void 0 ? defaultTotalHeight : bars.reduce(function (total, bar) { return total + yBarScale(bar.data); }, 0);
955
+ }
956
+ else {
957
+ // When displaying gaps between the bars, the height of each bar is
958
+ // adjusted so that the total of all bars is not changed by the gaps
959
+ totalData = bars.reduce(function (iter, value) { return iter + Math.abs(value.data); }, 0);
960
+ totalHeight =
961
+ defaultTotalHeight !== null && defaultTotalHeight !== void 0 ? defaultTotalHeight : Math.abs(yBarScale(totalData) - yBarScale(this.Y_ORIGIN));
962
+ bars.forEach(function (point) {
963
+ var value = (Math.abs(point.data) / totalData) * 100;
964
+ if (value < 1 && value !== 0) {
965
+ value = 1;
966
+ }
967
+ sumOfPercent += value;
968
+ });
969
+ scalingRatio = sumOfPercent !== 0 ? sumOfPercent / 100 : 1;
970
+ }
856
971
  var gaps = barGapMax && bars.length - 1;
857
972
  var gapHeight = gaps && Math.max(barGapMin, Math.min(barGapMax, (totalHeight * barGapMultiplier) / gaps));
858
- var heightValueScale = (totalHeight - gapHeight * gaps) / (totalData * scalingRatio);
973
+ var heightValueScale = this._yAxisType === index_3.YAxisType.StringAxis ? 0 : (totalHeight - gapHeight * gaps) / (totalData * scalingRatio);
859
974
  return {
860
975
  gapHeight: gapHeight,
861
976
  heightValueScale: heightValueScale,