@fluentui/react-charting 5.23.97 → 5.24.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 (156) hide show
  1. package/CHANGELOG.json +51 -1
  2. package/CHANGELOG.md +26 -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 +19 -12
  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 +24 -16
  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 +24 -16
  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
@@ -8,7 +8,8 @@ import { DirectionalHint } from '@fluentui/react/lib/Callout';
8
8
  import { Legends } from '../Legends/index';
9
9
  import { CartesianChart, ChartHoverCard, } from '../../index';
10
10
  import { FocusZoneDirection } from '@fluentui/react-focus';
11
- import { ChartTypes, getAccessibleDataObject, XAxisTypes, getTypeOfAxis, tooltipOfAxislabels, formatValueLimitWidth, getBarWidth, getScalePadding, isScalePaddingDefined, calculateAppropriateBarWidth, findVSBCNumericMinMaxOfY, createNumericYAxis, domainRangeOfDateForAreaLineVerticalBarChart, domainRangeOfVSBCNumeric, domainRangeOfXStringAxis, createStringYAxis, formatDate, getNextGradient, areArraysEqual, calculateLongestLabelWidth, } from '../../utilities/index';
11
+ import { formatDateToLocaleString } from '@fluentui/chart-utilities';
12
+ import { ChartTypes, getAccessibleDataObject, XAxisTypes, getTypeOfAxis, tooltipOfAxislabels, formatScientificLimitWidth, getBarWidth, getScalePadding, isScalePaddingDefined, calculateAppropriateBarWidth, findVSBCNumericMinMaxOfY, createNumericYAxis, domainRangeOfDateForAreaLineVerticalBarChart, domainRangeOfVSBCNumeric, domainRangeOfXStringAxis, createStringYAxis, getNextGradient, areArraysEqual, calculateLongestLabelWidth, YAxisType, } from '../../utilities/index';
12
13
  import { toImage } from '../../utilities/image-export-utils';
13
14
  var getClassNames = classNamesFunction();
14
15
  var COMPONENT_NAME = 'VERTICAL STACKED BAR CHART';
@@ -25,6 +26,7 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
25
26
  var _this = _super.call(this, props) || this;
26
27
  _this._isRtl = getRTL();
27
28
  _this.Y_ORIGIN = 0;
29
+ _this._yAxisLabels = [];
28
30
  _this.toImage = function (opts) {
29
31
  var _a, _b;
30
32
  return 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);
@@ -121,13 +123,20 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
121
123
  var useSecondaryYScale = lineObject[item][i - 1].useSecondaryYScale && lineObject[item][i].useSecondaryYScale && yScaleSecondary;
122
124
  var y1 = useSecondaryYScale
123
125
  ? yScaleSecondary(lineObject[item][i - 1].y)
124
- : yScalePrimary(lineObject[item][i - 1].y);
126
+ : //eslint-disable-next-line @typescript-eslint/no-explicit-any
127
+ yScalePrimary(lineObject[item][i - 1].y);
125
128
  var x2 = xScale(lineObject[item][i].xItem.xAxisPoint);
126
- var y2 = useSecondaryYScale ? yScaleSecondary(lineObject[item][i].y) : yScalePrimary(lineObject[item][i].y);
129
+ var y2 = useSecondaryYScale
130
+ ? yScaleSecondary(lineObject[item][i].y)
131
+ : //eslint-disable-next-line @typescript-eslint/no-explicit-any
132
+ yScalePrimary(lineObject[item][i].y);
133
+ var yScaleBandwidthTranslate = !useSecondaryYScale && _this._yAxisType === YAxisType.StringAxis
134
+ ? yScalePrimary.bandwidth() / 2
135
+ : 0;
127
136
  if (lineBorderWidth > 0) {
128
- 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)") }));
137
+ 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, ")") }));
129
138
  }
130
- 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 }));
139
+ 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 }));
131
140
  }
132
141
  });
133
142
  Object.keys(lineObject).forEach(function (item, index) {
@@ -135,12 +144,16 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
135
144
  // Create an object to store line point ref so that the object can be passed by reference to the focus handler
136
145
  var circleRef = { refElement: null };
137
146
  var noBarsActive = circlePoint.xItem.chartData.filter(function (dataPoint) { return _this._noLegendHighlighted() || _this._isLegendHighlighted(dataPoint.legend); }).length === 0;
147
+ var yScaleBandwidthTranslate = !circlePoint.useSecondaryYScale && _this._yAxisType === YAxisType.StringAxis
148
+ ? yScalePrimary.bandwidth() / 2
149
+ : 0;
138
150
  dots.push(React.createElement("circle", __assign({ key: "".concat(index, "-").concat(subIndex, "-dot"), cx: xScale(circlePoint.xItem.xAxisPoint), cy: circlePoint.useSecondaryYScale && yScaleSecondary
139
151
  ? yScaleSecondary(circlePoint.y)
140
- : 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,
152
+ : // eslint-disable-next-line @typescript-eslint/no-explicit-any
153
+ 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,
141
154
  // Elements with visibility: hidden cannot receive focus, so use opacity: 0 instead to hide them.
142
155
  // For more information, see https://fuzzbomb.github.io/accessibility-demos/visually-hidden-focus-test.html
143
- 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))
156
+ 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))
144
157
  ? {
145
158
  'data-is-focusable': !_this.props.hideTooltip,
146
159
  onFocus: _this._lineFocus.bind(_this, circlePoint, circleRef),
@@ -243,7 +256,12 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
243
256
  var xScaleBandwidthTranslate = _this._xAxisType !== XAxisTypes.StringAxis ? -_this._barWidth / 2 : (xBarScale.bandwidth() - _this._barWidth) / 2;
244
257
  var barTotalValue = 0;
245
258
  // Removing datapoints with zero data
246
- var barsToDisplay = singleChartData.chartData.filter(function (point) { return point.data !== 0; });
259
+ var barsToDisplay = singleChartData.chartData.filter(function (point) {
260
+ return point.data !== 0 &&
261
+ point.data !== '' &&
262
+ !(_this._yAxisType === YAxisType.StringAxis &&
263
+ typeof yBarScale(point.data) === 'undefined');
264
+ });
247
265
  if (!barsToDisplay.length) {
248
266
  return undefined;
249
267
  }
@@ -251,7 +269,9 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
251
269
  if (heightValueScale < 0) {
252
270
  return undefined;
253
271
  }
254
- var yBaseline = containerHeight - _this.margins.bottom - yBarScale(_this.Y_ORIGIN);
272
+ var yBaseline = containerHeight -
273
+ _this.margins.bottom -
274
+ (_this._yAxisType === YAxisType.StringAxis ? 0 : yBarScale(_this.Y_ORIGIN));
255
275
  var yPositiveStart = yBaseline;
256
276
  var yNegativeStart = yBaseline;
257
277
  var yPoint = 0;
@@ -284,22 +304,33 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
284
304
  onClick: _this._onClick.bind(_this, point),
285
305
  role: 'img',
286
306
  };
287
- var barHeight = Math.abs(heightValueScale * point.data);
288
- var minHeight = Math.max((heightValueScale * adjustedTotalHeight) / 100.0, barMinimumHeight);
289
- if (barHeight < minHeight) {
290
- barHeight = minHeight;
291
- }
307
+ var barHeight;
292
308
  var gapOffset = index ? gapHeight : 0;
293
- if (point.data >= _this.Y_ORIGIN) {
309
+ if (_this._yAxisType === YAxisType.StringAxis) {
310
+ barHeight = Math.max(containerHeight -
311
+ _this.margins.bottom -
312
+ (yBarScale(point.data) + yBarScale.bandwidth() / 2) -
313
+ gapOffset, barMinimumHeight, 1);
294
314
  yPositiveStart -= barHeight + gapOffset;
295
315
  yPoint = yPositiveStart;
296
316
  }
297
317
  else {
298
- yPoint = yNegativeStart + gapOffset;
299
- yNegativeStart = yPoint + barHeight;
318
+ barHeight = Math.abs(heightValueScale * point.data);
319
+ var minHeight = Math.max((heightValueScale * adjustedTotalHeight) / 100.0, barMinimumHeight);
320
+ if (barHeight < minHeight) {
321
+ barHeight = minHeight;
322
+ }
323
+ if (point.data >= _this.Y_ORIGIN) {
324
+ yPositiveStart -= barHeight + gapOffset;
325
+ yPoint = yPositiveStart;
326
+ }
327
+ else {
328
+ yPoint = yNegativeStart + gapOffset;
329
+ yNegativeStart = yPoint + barHeight;
330
+ }
331
+ barTotalValue += point.data;
332
+ heightOfLastBar = index === barsToDisplay.length - 1 ? barHeight : 0;
300
333
  }
301
- barTotalValue += point.data;
302
- heightOfLastBar = index === barsToDisplay.length - 1 ? barHeight : 0;
303
334
  var gradientId = getId('VSBC_Gradient') + "_".concat(indexNumber, "_").concat(index);
304
335
  // If set, apply the corner radius to the top of the final bar
305
336
  if (barCornerRadius && barHeight > barCornerRadius && index === barsToDisplay.length - 1) {
@@ -339,7 +370,7 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
339
370
  };
340
371
  var showLabel = false;
341
372
  var barLabel = 0;
342
- if (!_this.props.hideLabels) {
373
+ if (!_this.props.hideLabels && _this._yAxisType !== YAxisType.StringAxis) {
343
374
  if (_this._noLegendHighlighted()) {
344
375
  showLabel = true;
345
376
  barLabel = barTotalValue;
@@ -357,7 +388,7 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
357
388
  React.createElement("g", __assign({ id: "".concat(indexNumber, "-singleBar"), ref: function (e) { return (groupRef.refElement = e); } }, stackFocusProps), singleBar),
358
389
  !_this.props.hideLabels && _this._barWidth >= 16 && showLabel && (React.createElement("text", { x: xPoint + _this._barWidth / 2,
359
390
  //if total bar value >=0, show label above top bar, otherwise below bottom bar
360
- 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)") }, formatValueLimitWidth(barLabel)))));
391
+ 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)") }, formatScientificLimitWidth(barLabel)))));
361
392
  });
362
393
  // Removing un wanted tooltip div from DOM, when prop not provided.
363
394
  if (!_this.props.showXAxisLablesTooltip) {
@@ -426,7 +457,7 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
426
457
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
427
458
  xScale, yScale, containerHeight, containerWidth, xElement) {
428
459
  var _a = _this._getScales(containerHeight, containerWidth), xBarScale = _a.xBarScale, yBarScale = _a.yBarScale;
429
- return (_this._bars = _this._createBar(xBarScale, yBarScale, containerHeight, xElement));
460
+ return (_this._bars = _this._createBar(xBarScale, _this._yAxisType === YAxisType.StringAxis ? yScale : yBarScale, containerHeight, xElement));
430
461
  };
431
462
  _this._closeCallout = function () {
432
463
  _this.setState({
@@ -461,7 +492,7 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
461
492
  /** if shouldFocusWholeStack is true */
462
493
  var xValue_1 = singleChartData.xAxisCalloutData ||
463
494
  (singleChartData.xAxisPoint instanceof Date
464
- ? formatDate(singleChartData.xAxisPoint)
495
+ ? formatDateToLocaleString(singleChartData.xAxisPoint, _this.props.culture, _this.props.useUTC)
465
496
  : singleChartData.xAxisPoint);
466
497
  var pointValues = singleChartData.chartData
467
498
  .map(function (pt) {
@@ -483,7 +514,7 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
483
514
  var xValue = singleChartData.xAxisCalloutData ||
484
515
  (!isLinePoint && point.xAxisCalloutData) ||
485
516
  (singleChartData.xAxisPoint instanceof Date
486
- ? formatDate(singleChartData.xAxisPoint)
517
+ ? formatDateToLocaleString(singleChartData.xAxisPoint, _this.props.culture, _this.props.useUTC)
487
518
  : singleChartData.xAxisPoint);
488
519
  var legend = point.legend;
489
520
  var yValue = point.yAxisCalloutData ||
@@ -561,6 +592,70 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
561
592
  });
562
593
  return { startValue: d3Min(values), endValue: d3Max(values) };
563
594
  };
595
+ _this._initYAxisParams = function () {
596
+ if (_this._points[0].chartData.length > 0) {
597
+ _this._yAxisType = getTypeOfAxis(_this._points[0].chartData[0].data, false);
598
+ }
599
+ else {
600
+ Object.keys(_this._lineObject).forEach(function (lineLegend) {
601
+ if (!_this._lineObject[lineLegend][0].useSecondaryYScale) {
602
+ _this._yAxisType = getTypeOfAxis(_this._lineObject[lineLegend][0].y, false);
603
+ }
604
+ });
605
+ }
606
+ if (_this._yAxisType === YAxisType.StringAxis) {
607
+ var legendToYValues_1 = {};
608
+ _this._points.forEach(function (xPoint) {
609
+ xPoint.chartData.forEach(function (bar) {
610
+ if (!legendToYValues_1[bar.legend]) {
611
+ legendToYValues_1[bar.legend] = ["".concat(bar.data)];
612
+ }
613
+ else {
614
+ legendToYValues_1[bar.legend].push("".concat(bar.data));
615
+ }
616
+ });
617
+ });
618
+ var yAxisLabels_1 = new Set();
619
+ Object.values(legendToYValues_1).forEach(function (yValues) {
620
+ yValues.forEach(function (yVal) {
621
+ yAxisLabels_1.add(yVal);
622
+ });
623
+ });
624
+ Object.values(_this._lineObject).forEach(function (linePoints) {
625
+ linePoints.forEach(function (linePoint) {
626
+ if (!linePoint.useSecondaryYScale) {
627
+ yAxisLabels_1.add("".concat(linePoint.y));
628
+ }
629
+ });
630
+ });
631
+ _this._yAxisLabels = Array.from(yAxisLabels_1);
632
+ }
633
+ };
634
+ _this._getYDomainMargins = function (containerHeight) {
635
+ /**
636
+ * Specifies the extra top margin to apply above the highest y-axis tick label.
637
+ * Useful when stacked bars extend beyond the combined height of all y-axis labels (or categories).
638
+ */
639
+ var yAxisTickMarginTop = 0;
640
+ /** Total height available to render the bars */
641
+ var totalHeight = containerHeight - _this.margins.bottom - _this.margins.top;
642
+ if (_this._yAxisType === YAxisType.StringAxis) {
643
+ /** Maximum height of the stacked bars, expressed in multiples of the height of a y-axis label (or category) */
644
+ var maxBarHeightInLabels_1 = 0;
645
+ _this._points.forEach(function (xPoint) {
646
+ /** Height of the stacked bar, expressed in multiples of the height of a y-axis label (or category) */
647
+ var barHeightInLabels = 0;
648
+ xPoint.chartData.forEach(function (bar) {
649
+ barHeightInLabels += _this._yAxisLabels.indexOf("".concat(bar.data)) + 1;
650
+ });
651
+ maxBarHeightInLabels_1 = Math.max(maxBarHeightInLabels_1, barHeightInLabels);
652
+ });
653
+ /** Height of a y-axis label (or category) */
654
+ var yAxisLabelHeight = maxBarHeightInLabels_1 === 0 ? 0 : totalHeight / maxBarHeightInLabels_1;
655
+ yAxisTickMarginTop += yAxisLabelHeight * (maxBarHeightInLabels_1 - _this._yAxisLabels.length);
656
+ }
657
+ return __assign(__assign({}, _this.margins), { top: _this.margins.top + yAxisTickMarginTop });
658
+ };
564
659
  initializeComponentRef(_this);
565
660
  _this.state = {
566
661
  isCalloutVisible: false,
@@ -629,7 +724,7 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
629
724
  return (React.createElement(CartesianChart, __assign({}, this.props, { chartTitle: this._getChartTitle(), points: this._dataset, chartType: ChartTypes.VerticalStackedBarChart, xAxisType: this._xAxisType, calloutProps: calloutProps, createYAxis: createNumericYAxis, tickParams: tickParams, legendBars: legendBars, getMinMaxOfYAxis: this._getMinMaxOfYAxis, datasetForXAxisDomain: this._xAxisLabels, isCalloutForStack: shouldFocusWholeStack, getDomainNRangeValues: this._getDomainNRangeValues, createStringYAxis: createStringYAxis, barwidth: this._barWidth, focusZoneDirection: isCalloutForStack || _isHavingLines_1 ? FocusZoneDirection.horizontal : FocusZoneDirection.vertical, getmargins: this._getMargins, getGraphData: this._getGraphData, getAxisData: this._getAxisData, customizedCallout: this._getCustomizedCallout(), onChartMouseLeave: this._handleChartMouseLeave, getDomainMargins: this._getDomainMargins }, (this._xAxisType === XAxisTypes.StringAxis && {
630
725
  xAxisInnerPadding: this._xAxisInnerPadding,
631
726
  xAxisOuterPadding: this._xAxisOuterPadding,
632
- }), { ref: this._cartesianChartRef, showRoundOffXTickValues: !isScalePaddingDefined(this.props.xAxisInnerPadding, this.props.xAxisPadding),
727
+ }), { ref: this._cartesianChartRef, showRoundOffXTickValues: !isScalePaddingDefined(this.props.xAxisInnerPadding, this.props.xAxisPadding), yAxisType: this._yAxisType, stringDatasetForYAxisDomain: __spreadArray([''], this._yAxisLabels, true), getYDomainMargins: this._getYDomainMargins,
633
728
  /* eslint-disable react/jsx-no-bind */
634
729
  children: function (props) {
635
730
  return (React.createElement(React.Fragment, null,
@@ -659,15 +754,23 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
659
754
  this._lineObject = this._getFormattedLineData(this.props.data);
660
755
  this._xAxisInnerPadding = getScalePadding(this.props.xAxisInnerPadding, this.props.xAxisPadding, this._xAxisType === XAxisTypes.StringAxis ? 2 / 3 : 1 / 2);
661
756
  this._xAxisOuterPadding = getScalePadding(this.props.xAxisOuterPadding, this.props.xAxisPadding, 0);
757
+ this._initYAxisParams();
662
758
  };
663
759
  VerticalStackedBarChartBase.prototype._createDataSetLayer = function () {
760
+ var _this = this;
664
761
  var tempArr = [];
665
762
  var dataset = this._points.map(function (singlePointData) {
763
+ tempArr.push(singlePointData.xAxisPoint);
764
+ if (_this._yAxisType === YAxisType.StringAxis) {
765
+ return {
766
+ x: singlePointData.xAxisPoint,
767
+ y: 0,
768
+ };
769
+ }
666
770
  var total = 0;
667
771
  singlePointData.chartData.forEach(function (point) {
668
772
  total = total + point.data;
669
773
  });
670
- tempArr.push(singlePointData.xAxisPoint);
671
774
  return {
672
775
  x: singlePointData.xAxisPoint,
673
776
  y: total,
@@ -814,7 +917,9 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
814
917
  isCalloutVisible: stack.chartData.length > 0 || ((_c = (_b = stack.lineData) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0) > 0,
815
918
  YValueHover: isLinesPresent
816
919
  ? __spreadArray(__spreadArray([], lineData.sort(function (a, b) { return (a.data < b.data ? 1 : -1); }), true), stack.chartData.slice().reverse(), true) : stack.chartData.slice().reverse(),
817
- hoverXValue: stack.xAxisPoint instanceof Date ? formatDate(stack.xAxisPoint, this.props.useUTC) : stack.xAxisPoint,
920
+ hoverXValue: stack.xAxisPoint instanceof Date
921
+ ? formatDateToLocaleString(stack.xAxisPoint, this.props.culture, this.props.useUTC)
922
+ : stack.xAxisPoint,
818
923
  stackCalloutProps: stack,
819
924
  activeXAxisDataPoint: stack.xAxisPoint,
820
925
  callOutAccessibilityData: stack.stackCallOutAccessibilityData,
@@ -837,22 +942,32 @@ var VerticalStackedBarChartBase = /** @class */ (function (_super) {
837
942
  };
838
943
  VerticalStackedBarChartBase.prototype._getBarGapAndScale = function (bars, yBarScale, defaultTotalHeight) {
839
944
  var _a = this.props.barGapMax, barGapMax = _a === void 0 ? 0 : _a;
840
- // When displaying gaps between the bars, the height of each bar is
841
- // adjusted so that the total of all bars is not changed by the gaps
842
- var totalData = bars.reduce(function (iter, value) { return iter + Math.abs(value.data); }, 0);
843
- var totalHeight = defaultTotalHeight !== null && defaultTotalHeight !== void 0 ? defaultTotalHeight : Math.abs(yBarScale(totalData) - yBarScale(this.Y_ORIGIN));
945
+ var totalData = 0;
946
+ var totalHeight;
844
947
  var sumOfPercent = 0;
845
- bars.forEach(function (point) {
846
- var value = (Math.abs(point.data) / totalData) * 100;
847
- if (value < 1 && value !== 0) {
848
- value = 1;
849
- }
850
- sumOfPercent += value;
851
- });
852
- var scalingRatio = sumOfPercent !== 0 ? sumOfPercent / 100 : 1;
948
+ var scalingRatio;
949
+ if (this._yAxisType === YAxisType.StringAxis) {
950
+ totalHeight =
951
+ defaultTotalHeight !== null && defaultTotalHeight !== void 0 ? defaultTotalHeight : bars.reduce(function (total, bar) { return total + yBarScale(bar.data); }, 0);
952
+ }
953
+ else {
954
+ // When displaying gaps between the bars, the height of each bar is
955
+ // adjusted so that the total of all bars is not changed by the gaps
956
+ totalData = bars.reduce(function (iter, value) { return iter + Math.abs(value.data); }, 0);
957
+ totalHeight =
958
+ defaultTotalHeight !== null && defaultTotalHeight !== void 0 ? defaultTotalHeight : Math.abs(yBarScale(totalData) - yBarScale(this.Y_ORIGIN));
959
+ bars.forEach(function (point) {
960
+ var value = (Math.abs(point.data) / totalData) * 100;
961
+ if (value < 1 && value !== 0) {
962
+ value = 1;
963
+ }
964
+ sumOfPercent += value;
965
+ });
966
+ scalingRatio = sumOfPercent !== 0 ? sumOfPercent / 100 : 1;
967
+ }
853
968
  var gaps = barGapMax && bars.length - 1;
854
969
  var gapHeight = gaps && Math.max(barGapMin, Math.min(barGapMax, (totalHeight * barGapMultiplier) / gaps));
855
- var heightValueScale = (totalHeight - gapHeight * gaps) / (totalData * scalingRatio);
970
+ var heightValueScale = this._yAxisType === YAxisType.StringAxis ? 0 : (totalHeight - gapHeight * gaps) / (totalData * scalingRatio);
856
971
  return {
857
972
  gapHeight: gapHeight,
858
973
  heightValueScale: heightValueScale,