@fluentui/react-charts 9.2.1 → 9.2.3

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 (201) hide show
  1. package/CHANGELOG.md +57 -2
  2. package/dist/index.d.ts +168 -15
  3. package/lib/ChartTable.js +1 -0
  4. package/lib/ChartTable.js.map +1 -0
  5. package/lib/components/AreaChart/AreaChart.js +4 -1
  6. package/lib/components/AreaChart/AreaChart.js.map +1 -1
  7. package/lib/components/AreaChart/useAreaChartStyles.styles.js +2 -1
  8. package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
  9. package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js +2 -1
  10. package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
  11. package/lib/components/ChartTable/ChartTable.js +58 -0
  12. package/lib/components/ChartTable/ChartTable.js.map +1 -0
  13. package/lib/components/ChartTable/ChartTable.types.js +1 -0
  14. package/lib/components/ChartTable/ChartTable.types.js.map +1 -0
  15. package/lib/components/ChartTable/index.js +3 -0
  16. package/lib/components/ChartTable/index.js.map +1 -0
  17. package/lib/components/ChartTable/useChartTableStyles.styles.js +93 -0
  18. package/lib/components/ChartTable/useChartTableStyles.styles.js.map +1 -0
  19. package/lib/components/ChartTable/useChartTableStyles.styles.raw.js +55 -0
  20. package/lib/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -0
  21. package/lib/components/CommonComponents/CartesianChart.js +170 -100
  22. package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
  23. package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
  24. package/lib/components/CommonComponents/ChartPopover.types.js.map +1 -1
  25. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +13 -0
  26. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  27. package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +12 -0
  28. package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
  29. package/lib/components/DeclarativeChart/DeclarativeChart.js +180 -102
  30. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  31. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +100 -0
  32. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
  33. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +890 -211
  34. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  35. package/lib/components/DonutChart/DonutChart.js +2 -2
  36. package/lib/components/DonutChart/DonutChart.js.map +1 -1
  37. package/lib/components/DonutChart/DonutChart.types.js.map +1 -1
  38. package/lib/components/DonutChart/Pie/Pie.js.map +1 -1
  39. package/lib/components/FunnelChart/FunnelChart.js.map +1 -1
  40. package/lib/components/GanttChart/GanttChart.js.map +1 -1
  41. package/lib/components/GanttChart/useGanttChartStyles.styles.js +2 -1
  42. package/lib/components/GanttChart/useGanttChartStyles.styles.js.map +1 -1
  43. package/lib/components/GanttChart/useGanttChartStyles.styles.raw.js +2 -1
  44. package/lib/components/GanttChart/useGanttChartStyles.styles.raw.js.map +1 -1
  45. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +185 -144
  46. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  47. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +2 -1
  48. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  49. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +2 -1
  50. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
  51. package/lib/components/HeatMapChart/HeatMapChart.js +175 -114
  52. package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
  53. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js +2 -1
  54. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
  55. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +2 -1
  56. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
  57. package/lib/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
  58. package/lib/components/HorizontalBarChart/HorizontalBarChart.types.js.map +1 -1
  59. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +26 -6
  60. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  61. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +2 -1
  62. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
  63. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +2 -1
  64. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
  65. package/lib/components/Legends/Legends.js.map +1 -1
  66. package/lib/components/Legends/OverflowMenu.js.map +1 -1
  67. package/lib/components/LineChart/LineChart.js +251 -78
  68. package/lib/components/LineChart/LineChart.js.map +1 -1
  69. package/lib/components/LineChart/LineChart.types.js.map +1 -1
  70. package/lib/components/LineChart/useLineChartStyles.styles.js +10 -3
  71. package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  72. package/lib/components/LineChart/useLineChartStyles.styles.raw.js +14 -2
  73. package/lib/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
  74. package/lib/components/ScatterChart/ScatterChart.js +56 -37
  75. package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
  76. package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -1
  77. package/lib/components/ScatterChart/useScatterChartStyles.styles.js +21 -4
  78. package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  79. package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js +16 -3
  80. package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
  81. package/lib/components/VerticalBarChart/VerticalBarChart.js +38 -14
  82. package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  83. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +2 -1
  84. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  85. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +2 -1
  86. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
  87. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +214 -96
  88. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  89. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
  90. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +2 -1
  91. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
  92. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +2 -1
  93. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
  94. package/lib/index.js +1 -0
  95. package/lib/index.js.map +1 -1
  96. package/lib/types/DataPoint.js.map +1 -1
  97. package/lib/utilities/FocusableTooltipText.js.map +1 -1
  98. package/lib/utilities/utilities.js +41 -42
  99. package/lib/utilities/utilities.js.map +1 -1
  100. package/lib/utilities/vbc-utils.js +24 -0
  101. package/lib/utilities/vbc-utils.js.map +1 -1
  102. package/lib-commonjs/ChartTable.js +6 -0
  103. package/lib-commonjs/ChartTable.js.map +1 -0
  104. package/lib-commonjs/components/AreaChart/AreaChart.js +4 -1
  105. package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
  106. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js +2 -1
  107. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
  108. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js +2 -1
  109. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
  110. package/lib-commonjs/components/ChartTable/ChartTable.js +69 -0
  111. package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -0
  112. package/lib-commonjs/components/ChartTable/ChartTable.types.js +6 -0
  113. package/lib-commonjs/components/ChartTable/ChartTable.types.js.map +1 -0
  114. package/lib-commonjs/components/ChartTable/index.js +8 -0
  115. package/lib-commonjs/components/ChartTable/index.js.map +1 -0
  116. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js +196 -0
  117. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js.map +1 -0
  118. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js +69 -0
  119. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -0
  120. package/lib-commonjs/components/CommonComponents/CartesianChart.js +169 -98
  121. package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
  122. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
  123. package/lib-commonjs/components/CommonComponents/ChartPopover.types.js.map +1 -1
  124. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +13 -0
  125. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  126. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +12 -0
  127. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
  128. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +176 -100
  129. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  130. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +128 -0
  131. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
  132. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +909 -209
  133. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  134. package/lib-commonjs/components/DonutChart/DonutChart.js +1 -1
  135. package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
  136. package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -1
  137. package/lib-commonjs/components/DonutChart/Pie/Pie.js.map +1 -1
  138. package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -1
  139. package/lib-commonjs/components/GanttChart/GanttChart.js.map +1 -1
  140. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js +2 -1
  141. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js.map +1 -1
  142. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.raw.js +2 -1
  143. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.raw.js.map +1 -1
  144. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +183 -142
  145. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  146. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +2 -1
  147. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  148. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +2 -1
  149. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
  150. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +174 -113
  151. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
  152. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js +2 -1
  153. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
  154. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +2 -1
  155. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
  156. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
  157. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.types.js.map +1 -1
  158. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +25 -5
  159. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  160. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +2 -1
  161. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
  162. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +2 -1
  163. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
  164. package/lib-commonjs/components/Legends/Legends.js.map +1 -1
  165. package/lib-commonjs/components/Legends/OverflowMenu.js.map +1 -1
  166. package/lib-commonjs/components/LineChart/LineChart.js +250 -78
  167. package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
  168. package/lib-commonjs/components/LineChart/LineChart.types.js.map +1 -1
  169. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js +12 -3
  170. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  171. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js +14 -2
  172. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
  173. package/lib-commonjs/components/ScatterChart/ScatterChart.js +56 -37
  174. package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
  175. package/lib-commonjs/components/ScatterChart/ScatterChart.types.js.map +1 -1
  176. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js +30 -3
  177. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  178. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js +15 -2
  179. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
  180. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +37 -13
  181. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  182. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +2 -1
  183. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  184. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +2 -1
  185. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
  186. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +213 -95
  187. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  188. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
  189. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +2 -1
  190. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
  191. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +2 -1
  192. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
  193. package/lib-commonjs/index.js +1 -0
  194. package/lib-commonjs/index.js.map +1 -1
  195. package/lib-commonjs/types/DataPoint.js.map +1 -1
  196. package/lib-commonjs/utilities/FocusableTooltipText.js.map +1 -1
  197. package/lib-commonjs/utilities/utilities.js +44 -41
  198. package/lib-commonjs/utilities/utilities.js.map +1 -1
  199. package/lib-commonjs/utilities/vbc-utils.js +27 -0
  200. package/lib-commonjs/utilities/vbc-utils.js.map +1 -1
  201. package/package.json +10 -10
@@ -19,15 +19,15 @@ const _reacttheme = require("@fluentui/react-theme");
19
19
  const _index = require("../../index");
20
20
  const _index1 = require("../../utilities/index");
21
21
  const _imageexportutils = require("../../utilities/image-export-utils");
22
+ const _chartutilities = require("@fluentui/chart-utilities");
22
23
  const barGapMultiplier = 0.2;
23
24
  const barGapMin = 1;
24
25
  const MIN_DOMAIN_MARGIN = 8;
25
- var CircleVisbility = /*#__PURE__*/ function(CircleVisbility) {
26
- CircleVisbility["show"] = "visibility";
27
- CircleVisbility["hide"] = "hidden";
28
- return CircleVisbility;
29
- }(CircleVisbility || {});
30
- const VerticalStackedBarChart = (props)=>{
26
+ const VerticalStackedBarChart = /*#__PURE__*/ _react.forwardRef((props = {
27
+ xAxisCategoryOrder: 'default',
28
+ yAxisCategoryOrder: 'default',
29
+ data: []
30
+ }, forwardedRef)=>{
31
31
  var _props_legendProps;
32
32
  const _isRtl = (0, _index1.useRtl)();
33
33
  const _createLegendsForLine = (data)=>_getLineLegends(data);
@@ -51,6 +51,8 @@ const VerticalStackedBarChart = (props)=>{
51
51
  const cartesianChartRef = _react.useRef(null);
52
52
  const Y_ORIGIN = 0;
53
53
  const _legendsRef = _react.useRef(null);
54
+ let _yAxisType;
55
+ let _yAxisLabels = [];
54
56
  const [selectedLegends, setSelectedLegends] = _react.useState(((_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.selectedLegends) || []);
55
57
  const [activeLegend, setActiveLegend] = _react.useState(undefined);
56
58
  const [dataForHoverCard, setDataForHoverCard] = _react.useState(0);
@@ -161,19 +163,29 @@ const VerticalStackedBarChart = (props)=>{
161
163
  activeLegend
162
164
  ] : [];
163
165
  }
164
- function _lineHoverOut() {
165
- setPopoverOpen(false);
166
- setXCalloutValue('');
167
- setYCalloutValue('');
168
- setActiveXAxisDataPoint('');
169
- setColor('');
170
- }
171
- function _lineHoverFocus(lineData) {
172
- setPopoverOpen(true);
173
- setXCalloutValue(`${lineData.xItem.xAxisPoint}`);
174
- setYCalloutValue(`${lineData.yAxisCalloutData || lineData.data || lineData.y}`);
175
- setActiveXAxisDataPoint(lineData.xItem.xAxisPoint);
176
- setColor(lineData.color);
166
+ function _lineHoverFocus(lineData, event) {
167
+ let clientX = 0;
168
+ let clientY = 0;
169
+ if ('clientX' in event) {
170
+ clientX = event.clientX;
171
+ clientY = event.clientY;
172
+ } else {
173
+ const boundingRect = event.target.getBoundingClientRect();
174
+ clientX = boundingRect.left + boundingRect.width / 2;
175
+ clientY = boundingRect.top + boundingRect.height / 2;
176
+ }
177
+ if (_getHighlightedLegend().length === 1) {
178
+ if (_noLegendHighlighted() || _isLegendHighlighted(lineData.legend)) {
179
+ _updatePosition(clientX, clientY);
180
+ setPopoverOpen(true);
181
+ setXCalloutValue(`${lineData.xItem.xAxisPoint}`);
182
+ setYCalloutValue(`${lineData.yAxisCalloutData || lineData.data || lineData.y}`);
183
+ setActiveXAxisDataPoint(lineData.xItem.xAxisPoint);
184
+ setColor(lineData.color);
185
+ }
186
+ } else {
187
+ _onStackHoverFocus(lineData.xItem, event);
188
+ }
177
189
  }
178
190
  function _onStackHoverFocus(stack, mouseEvent) {
179
191
  var _stack_lineData;
@@ -241,21 +253,26 @@ const VerticalStackedBarChart = (props)=>{
241
253
  _lineObject = _getFormattedLineData(props.data);
242
254
  _xAxisInnerPadding = (0, _index1.getScalePadding)(props.xAxisInnerPadding, props.xAxisPadding, _xAxisType === _index1.XAxisTypes.StringAxis ? 2 / 3 : 1 / 2);
243
255
  _xAxisOuterPadding = (0, _index1.getScalePadding)(props.xAxisOuterPadding, props.xAxisPadding, 0);
256
+ _initYAxisParams();
244
257
  }
245
258
  function _createDataSetLayer() {
246
- const tempArr = [];
247
259
  const dataset = _points.map((singlePointData)=>{
260
+ if (_yAxisType === _index1.YAxisType.StringAxis) {
261
+ return {
262
+ x: singlePointData.xAxisPoint,
263
+ y: 0
264
+ };
265
+ }
248
266
  let total = 0;
249
267
  singlePointData.chartData.forEach((point)=>{
250
268
  total = total + point.data;
251
269
  });
252
- tempArr.push(singlePointData.xAxisPoint);
253
270
  return {
254
271
  x: singlePointData.xAxisPoint,
255
272
  y: total
256
273
  };
257
274
  });
258
- _xAxisLabels = tempArr;
275
+ _xAxisLabels = _getOrderedXAxisLabels();
259
276
  return dataset;
260
277
  }
261
278
  function _onLegendHover(legendTitle) {
@@ -280,7 +297,7 @@ const VerticalStackedBarChart = (props)=>{
280
297
  }
281
298
  function _getGraphData(xScale, yScale, containerHeight, containerWidth, xElement) {
282
299
  const { xBarScale, yBarScale } = _getScales(containerHeight, containerWidth);
283
- return _bars = _createBar(xBarScale, yBarScale, containerHeight, xElement);
300
+ return _bars = _createBar(xBarScale, _yAxisType === _index1.YAxisType.StringAxis ? yScale : yBarScale, containerHeight, xElement);
284
301
  }
285
302
  function _getAxisData(yAxisData) {
286
303
  if (yAxisData && yAxisData.yAxisDomainValues.length) {
@@ -290,19 +307,19 @@ const VerticalStackedBarChart = (props)=>{
290
307
  }
291
308
  }
292
309
  /**
293
- * This function checks if the given legend is highlighted or not.
294
- * A legend can be highlighted in 2 ways:
295
- * 1. selection: if the user clicks on it
296
- * 2. hovering: if there is no selected legend and the user hovers over it
297
- */ function _isLegendHighlighted(legendTitle) {
310
+ * This function checks if the given legend is highlighted or not.
311
+ * A legend can be highlighted in 2 ways:
312
+ * 1. selection: if the user clicks on it
313
+ * 2. hovering: if there is no selected legend and the user hovers over it
314
+ */ function _isLegendHighlighted(legendTitle) {
298
315
  return _getHighlightedLegend().includes(legendTitle);
299
316
  }
300
317
  /**
301
- * This function checks if none of the legends is selected or hovered.
302
- */ function _noLegendHighlighted() {
318
+ * This function checks if none of the legends is selected or hovered.
319
+ */ function _noLegendHighlighted() {
303
320
  return _getHighlightedLegend().length === 0;
304
321
  }
305
- function _getAriaLabel(singleChartData, point) {
322
+ function _getAriaLabel(singleChartData, point, isLinePoint) {
306
323
  var _point_callOutAccessibilityData;
307
324
  if (!point) {
308
325
  var _singleChartData_lineData, _singleChartData_stackCallOutAccessibilityData;
@@ -310,19 +327,19 @@ const VerticalStackedBarChart = (props)=>{
310
327
  const pointValues = singleChartData.chartData.map((pt)=>{
311
328
  const legend = pt.legend;
312
329
  const yValue = pt.yAxisCalloutData || pt.data;
313
- return `${legend}, ${yValue}.`;
314
- }).join(' ');
330
+ return _noLegendHighlighted() || _isLegendHighlighted(legend) ? `${legend}, ${yValue}.` : '';
331
+ }).filter((str)=>str !== '').join(' ');
315
332
  const lineValues = (_singleChartData_lineData = singleChartData.lineData) === null || _singleChartData_lineData === void 0 ? void 0 : _singleChartData_lineData.map((ln)=>{
316
333
  const legend = ln.legend;
317
334
  const yValue = ln.yAxisCalloutData || ln.data || ln.y;
318
- return `${legend}, ${yValue}.`;
319
- }).join(' ');
335
+ return _noLegendHighlighted() || _isLegendHighlighted(legend) ? `${legend}, ${yValue}.` : '';
336
+ }).filter((str)=>str !== '').join(' ');
320
337
  return ((_singleChartData_stackCallOutAccessibilityData = singleChartData.stackCallOutAccessibilityData) === null || _singleChartData_stackCallOutAccessibilityData === void 0 ? void 0 : _singleChartData_stackCallOutAccessibilityData.ariaLabel) || `${xValue}. ${pointValues}` + (lineValues ? ` ${lineValues}` : '');
321
338
  }
322
- /** if shouldFocusWholeStack is false */ const xValue = singleChartData.xAxisCalloutData || point.xAxisCalloutData || (singleChartData.xAxisPoint instanceof Date ? (0, _index1.formatDate)(singleChartData.xAxisPoint) : singleChartData.xAxisPoint);
339
+ /** if shouldFocusWholeStack is false */ const xValue = singleChartData.xAxisCalloutData || !isLinePoint && point.xAxisCalloutData || (singleChartData.xAxisPoint instanceof Date ? (0, _index1.formatDate)(singleChartData.xAxisPoint) : singleChartData.xAxisPoint);
323
340
  const legend = point.legend;
324
- const yValue = point.yAxisCalloutData || point.data;
325
- return ((_point_callOutAccessibilityData = point.callOutAccessibilityData) === null || _point_callOutAccessibilityData === void 0 ? void 0 : _point_callOutAccessibilityData.ariaLabel) || `${xValue}. ${legend}, ${yValue}.`;
341
+ const yValue = point.yAxisCalloutData || (isLinePoint ? point.data || point.y : point.data);
342
+ return !isLinePoint && ((_point_callOutAccessibilityData = point.callOutAccessibilityData) === null || _point_callOutAccessibilityData === void 0 ? void 0 : _point_callOutAccessibilityData.ariaLabel) || `${xValue}. ${legend}, ${yValue}.`;
326
343
  }
327
344
  function _getCustomizedCallout() {
328
345
  const _isHavingLines = props.data.some((item)=>item.lineData && item.lineData.length > 0);
@@ -407,6 +424,7 @@ const VerticalStackedBarChart = (props)=>{
407
424
  const y1 = useSecondaryYScale ? yScaleSecondary(lineObject[item][i - 1].y) : yScalePrimary(lineObject[item][i - 1].y);
408
425
  const x2 = xScale(lineObject[item][i].xItem.xAxisPoint);
409
426
  const y2 = useSecondaryYScale ? yScaleSecondary(lineObject[item][i].y) : yScalePrimary(lineObject[item][i].y);
427
+ const yScaleBandwidthTranslate = !useSecondaryYScale && _yAxisType === _index1.YAxisType.StringAxis ? yScalePrimary.bandwidth() / 2 : 0;
410
428
  if (lineBorderWidth > 0) {
411
429
  borderForLines.push(/*#__PURE__*/ _react.createElement("line", {
412
430
  key: `${index}-${i}-BorderLine`,
@@ -419,7 +437,7 @@ const VerticalStackedBarChart = (props)=>{
419
437
  fill: "transparent",
420
438
  strokeLinecap: "round",
421
439
  stroke: _reacttheme.tokens.colorNeutralBackground1,
422
- transform: `translate(${xScaleBandwidthTranslate}, 0)`
440
+ transform: `translate(${xScaleBandwidthTranslate}, ${yScaleBandwidthTranslate})`
423
441
  }));
424
442
  }
425
443
  var _lineObject_item__lineOptions_strokeWidth, _lineObject_item__lineOptions_strokeLinecap;
@@ -434,11 +452,9 @@ const VerticalStackedBarChart = (props)=>{
434
452
  strokeLinecap: (_lineObject_item__lineOptions_strokeLinecap = (_lineObject_item__lineOptions1 = lineObject[item][0].lineOptions) === null || _lineObject_item__lineOptions1 === void 0 ? void 0 : _lineObject_item__lineOptions1.strokeLinecap) !== null && _lineObject_item__lineOptions_strokeLinecap !== void 0 ? _lineObject_item__lineOptions_strokeLinecap : 'round',
435
453
  strokeDasharray: (_lineObject_item__lineOptions2 = lineObject[item][0].lineOptions) === null || _lineObject_item__lineOptions2 === void 0 ? void 0 : _lineObject_item__lineOptions2.strokeDasharray,
436
454
  stroke: lineObject[item][i].color,
437
- transform: `translate(${xScaleBandwidthTranslate}, 0)`,
438
- ..._isLegendHighlighted(item) && {
439
- onMouseOver: _lineHover.bind(lineObject[item][i - 1]),
440
- onMouseLeave: _lineHoverOut
441
- }
455
+ transform: `translate(${xScaleBandwidthTranslate}, ${yScaleBandwidthTranslate})`,
456
+ onMouseOver: (event)=>_lineHover(lineObject[item][i - 1], event),
457
+ onMouseLeave: _handleMouseOut
442
458
  }));
443
459
  }
444
460
  });
@@ -448,20 +464,21 @@ const VerticalStackedBarChart = (props)=>{
448
464
  refElement: null
449
465
  };
450
466
  const noBarsAndLinesActive = circlePoint.xItem.chartData.filter((dataPoint)=>_noLegendHighlighted() || _isLegendHighlighted(dataPoint.legend)).length === 0;
467
+ const yScaleBandwidthTranslate = !circlePoint.useSecondaryYScale && _yAxisType === _index1.YAxisType.StringAxis ? yScalePrimary.bandwidth() / 2 : 0;
451
468
  dots.push(/*#__PURE__*/ _react.createElement("circle", {
452
469
  key: `${index}-${subIndex}-dot`,
453
470
  cx: xScale(circlePoint.xItem.xAxisPoint),
454
471
  cy: circlePoint.useSecondaryYScale && yScaleSecondary ? yScaleSecondary(circlePoint.y) : yScalePrimary(circlePoint.y),
455
- onMouseOver: _isLegendHighlighted(item) ? (event)=>_lineHover(circlePoint, event) : (event)=>_onStackHover(circlePoint.xItem, event),
456
- ..._isLegendHighlighted(item) && {
457
- onMouseLeave: _lineHoverOut
458
- },
459
- r: _getCircleVisibilityAndRadius(circlePoint.xItem.xAxisPoint, circlePoint.legend).radius,
472
+ onMouseOver: (event)=>_lineHover(circlePoint, event),
473
+ onMouseLeave: _handleMouseOut,
474
+ r: _getCircleOpacityAndRadius(circlePoint.xItem.xAxisPoint, circlePoint.legend).radius,
460
475
  stroke: circlePoint.color,
461
476
  fill: _reacttheme.tokens.colorNeutralBackground1,
462
477
  strokeWidth: 3,
463
- visibility: _getCircleVisibilityAndRadius(circlePoint.xItem.xAxisPoint, circlePoint.legend).visibility,
464
- transform: `translate(${xScaleBandwidthTranslate}, 0)`,
478
+ // Elements with visibility: hidden cannot receive focus, so use opacity: 0 instead to hide them.
479
+ // For more information, see https://fuzzbomb.github.io/accessibility-demos/visually-hidden-focus-test.html
480
+ opacity: _getCircleOpacityAndRadius(circlePoint.xItem.xAxisPoint, circlePoint.legend).opacity,
481
+ transform: `translate(${xScaleBandwidthTranslate}, ${yScaleBandwidthTranslate})`,
465
482
  ref: (e)=>circleRef.refElement = e,
466
483
  ...noBarsAndLinesActive ? {
467
484
  tabIndex: !props.hideTooltip ? 0 : undefined,
@@ -475,27 +492,27 @@ const VerticalStackedBarChart = (props)=>{
475
492
  });
476
493
  return /*#__PURE__*/ _react.createElement(_react.Fragment, null, borderForLines, lines, dots);
477
494
  }
478
- function _getCircleVisibilityAndRadius(xAxisPoint, legend) {
495
+ function _getCircleOpacityAndRadius(xAxisPoint, legend) {
479
496
  if (!_noLegendHighlighted()) {
480
497
  if (xAxisPoint === activeXAxisDataPoint && _isLegendHighlighted(legend)) {
481
498
  return {
482
- visibility: "visibility",
499
+ opacity: 1,
483
500
  radius: 8
484
501
  };
485
502
  } else if (_isLegendHighlighted(legend)) {
486
503
  return {
487
- visibility: "visibility",
504
+ opacity: 1,
488
505
  radius: 0.3
489
506
  };
490
507
  } else {
491
508
  return {
492
- visibility: "hidden",
509
+ opacity: 0,
493
510
  radius: 0
494
511
  };
495
512
  }
496
513
  } else {
497
514
  return {
498
- visibility: activeXAxisDataPoint === xAxisPoint ? "visibility" : "hidden",
515
+ opacity: activeXAxisDataPoint === xAxisPoint ? 1 : 0,
499
516
  radius: 8
500
517
  };
501
518
  }
@@ -533,14 +550,15 @@ const VerticalStackedBarChart = (props)=>{
533
550
  if ((_calloutAnchorPoint === null || _calloutAnchorPoint === void 0 ? void 0 : _calloutAnchorPoint.chartDataPoint) !== point || (_calloutAnchorPoint === null || _calloutAnchorPoint === void 0 ? void 0 : _calloutAnchorPoint.xAxisDataPoint) !== xAxisPoint) {
534
551
  _calloutAnchorPoint = {
535
552
  chartDataPoint: point,
536
- xAxisDataPoint: `${xAxisPoint}`
553
+ xAxisDataPoint: xAxisPoint instanceof Date ? (0, _chartutilities.formatDateToLocaleString)(xAxisPoint, props.culture, props.useUTC) : xAxisPoint.toString()
537
554
  };
555
+ const xCalloutValue = point.xAxisCalloutData || (xAxisPoint instanceof Date ? (0, _chartutilities.formatDateToLocaleString)(xAxisPoint, props.culture, props.useUTC) : xAxisPoint.toString());
538
556
  _updatePosition(clientX, clientY);
539
557
  setPopoverOpen(_noLegendHighlighted() || _isLegendHighlighted(point.legend));
540
558
  setCalloutLegend(point.legend);
541
559
  setDataForHoverCard(point.data);
542
560
  setColor(color);
543
- setXCalloutValue(point.xAxisCalloutData ? point.xAxisCalloutData : `${xAxisPoint}`);
561
+ setXCalloutValue(xCalloutValue);
544
562
  setYCalloutValue(point.yAxisCalloutData);
545
563
  setDataPointCalloutProps(point);
546
564
  setCallOutAccessibilityData(point.callOutAccessibilityData);
@@ -548,11 +566,11 @@ const VerticalStackedBarChart = (props)=>{
548
566
  }
549
567
  function _lineHover(lineData, mouseEvent) {
550
568
  mouseEvent.persist();
551
- _lineHoverFocus(lineData);
569
+ _lineHoverFocus(lineData, mouseEvent);
552
570
  }
553
571
  function _lineFocus(event, lineData, ref) {
554
572
  if (ref.refElement) {
555
- _lineHoverFocus(lineData);
573
+ _lineHoverFocus(lineData, event);
556
574
  }
557
575
  }
558
576
  function _onStackHover(stack, mouseEvent) {
@@ -574,22 +592,29 @@ const VerticalStackedBarChart = (props)=>{
574
592
  }
575
593
  function _getBarGapAndScale(bars, yBarScale, defaultTotalHeight) {
576
594
  const { barGapMax = 0 } = props;
577
- // When displaying gaps between the bars, the height of each bar is
578
- // adjusted so that the total of all bars is not changed by the gaps
579
- const totalData = bars.reduce((iter, value)=>iter + Math.abs(value.data), 0);
580
- const totalHeight = defaultTotalHeight !== null && defaultTotalHeight !== void 0 ? defaultTotalHeight : Math.abs(yBarScale(totalData) - yBarScale(Y_ORIGIN));
595
+ let totalData = 0;
596
+ let totalHeight;
581
597
  let sumOfPercent = 0;
582
- bars.forEach((point)=>{
583
- let value = Math.abs(point.data) / totalData * 100;
584
- if (value < 1 && value !== 0) {
585
- value = 1;
586
- }
587
- sumOfPercent += value;
588
- });
589
- const scalingRatio = sumOfPercent !== 0 ? sumOfPercent / 100 : 1;
598
+ let scalingRatio;
599
+ if (_yAxisType === _index1.YAxisType.StringAxis) {
600
+ totalHeight = defaultTotalHeight !== null && defaultTotalHeight !== void 0 ? defaultTotalHeight : bars.reduce((total, bar)=>total + yBarScale(bar.data), 0);
601
+ } else {
602
+ // When displaying gaps between the bars, the height of each bar is
603
+ // adjusted so that the total of all bars is not changed by the gaps
604
+ totalData = bars.reduce((iter, value)=>iter + Math.abs(value.data), 0);
605
+ totalHeight = defaultTotalHeight !== null && defaultTotalHeight !== void 0 ? defaultTotalHeight : Math.abs(yBarScale(totalData) - yBarScale(Y_ORIGIN));
606
+ bars.forEach((point)=>{
607
+ let value = Math.abs(point.data) / totalData * 100;
608
+ if (value < 1 && value !== 0) {
609
+ value = 1;
610
+ }
611
+ sumOfPercent += value;
612
+ });
613
+ scalingRatio = sumOfPercent !== 0 ? sumOfPercent / 100 : 1;
614
+ }
590
615
  const gaps = barGapMax && bars.length - 1;
591
616
  const gapHeight = gaps && Math.max(barGapMin, Math.min(barGapMax, totalHeight * barGapMultiplier / gaps));
592
- const heightValueScale = (totalHeight - gapHeight * gaps) / (totalData * scalingRatio);
617
+ const heightValueScale = _yAxisType === _index1.YAxisType.StringAxis ? 0 : (totalHeight - gapHeight * gaps) / (totalData * scalingRatio);
593
618
  return {
594
619
  gapHeight,
595
620
  heightValueScale,
@@ -680,8 +705,7 @@ const VerticalStackedBarChart = (props)=>{
680
705
  }
681
706
  function _getDomainMargins(containerWidth) {
682
707
  _domainMargin = MIN_DOMAIN_MARGIN;
683
- /** Total width available to render the bars */ const totalWidth = containerWidth - (_margins.left + MIN_DOMAIN_MARGIN) - (_margins.right + MIN_DOMAIN_MARGIN);
684
- /** Rate at which the space between the bars changes wrt the bar width */ const barGapRate = _xAxisInnerPadding / (1 - _xAxisInnerPadding);
708
+ const totalWidth = (0, _index1.calcTotalWidth)(containerWidth, _margins, MIN_DOMAIN_MARGIN);
685
709
  if (_xAxisType === _index1.XAxisTypes.StringAxis) {
686
710
  if ((0, _index1.isScalePaddingDefined)(props.xAxisOuterPadding, props.xAxisPadding)) {
687
711
  // Setting the domain margin for string x-axis to 0 because the xAxisOuterPadding prop is now available
@@ -691,16 +715,16 @@ const VerticalStackedBarChart = (props)=>{
691
715
  // Update the bar width so that when CartesianChart rerenders,
692
716
  // the following calculations don't use the previous bar width.
693
717
  _barWidth = (0, _index1.getBarWidth)(props.barWidth, props.maxBarWidth);
694
- /** Total width required to render the bars. Directly proportional to bar width */ const reqWidth = (_xAxisLabels.length + (_xAxisLabels.length - 1) * barGapRate) * _barWidth;
718
+ /** Total width required to render the bars. Directly proportional to bar width */ const reqWidth = (0, _index1.calcRequiredWidth)(_barWidth, _xAxisLabels.length, _xAxisInnerPadding);
695
719
  if (totalWidth >= reqWidth) {
696
720
  // Center align the chart by setting equal left and right margins for domain
697
721
  _domainMargin = MIN_DOMAIN_MARGIN + (totalWidth - reqWidth) / 2;
698
722
  }
699
723
  } else if (props.mode === 'plotly' && _xAxisLabels.length > 1) {
700
724
  // Calculate the remaining width after rendering bars at their maximum allowable width
701
- const bandwidth = totalWidth / (_xAxisLabels.length + (_xAxisLabels.length - 1) * barGapRate);
725
+ const bandwidth = (0, _index1.calcBandwidth)(totalWidth, _xAxisLabels.length, _xAxisInnerPadding);
702
726
  const barWidth = (0, _index1.getBarWidth)(props.barWidth, props.maxBarWidth, bandwidth);
703
- let reqWidth = (_xAxisLabels.length + (_xAxisLabels.length - 1) * barGapRate) * barWidth;
727
+ let reqWidth = (0, _index1.calcRequiredWidth)(barWidth, _xAxisLabels.length, _xAxisInnerPadding);
704
728
  const margin1 = (totalWidth - reqWidth) / 2;
705
729
  let margin2 = Number.POSITIVE_INFINITY;
706
730
  if (!props.hideTickOverlap) {
@@ -740,7 +764,7 @@ const VerticalStackedBarChart = (props)=>{
740
764
  const xPoint = xBarScale(_xAxisType === _index1.XAxisTypes.NumericAxis ? singleChartData.xAxisPoint : _xAxisType === _index1.XAxisTypes.DateAxis ? singleChartData.xAxisPoint : singleChartData.xAxisPoint);
741
765
  const xScaleBandwidthTranslate = _xAxisType !== _index1.XAxisTypes.StringAxis ? -_barWidth / 2 : (xBarScale.bandwidth() - _barWidth) / 2;
742
766
  let barTotalValue = 0;
743
- const barsToDisplay = singleChartData.chartData.filter((point)=>point.data !== 0);
767
+ const barsToDisplay = singleChartData.chartData.filter((point)=>point.data !== 0 && point.data !== '' && !(_yAxisType === _index1.YAxisType.StringAxis && typeof yBarScale(point.data) === 'undefined'));
744
768
  if (!barsToDisplay.length) {
745
769
  return undefined;
746
770
  }
@@ -748,7 +772,7 @@ const VerticalStackedBarChart = (props)=>{
748
772
  if (heightValueScale < 0) {
749
773
  return undefined;
750
774
  }
751
- const yBaseline = containerHeight - _margins.bottom - yBarScale(Y_ORIGIN);
775
+ const yBaseline = containerHeight - _margins.bottom - (_yAxisType === _index1.YAxisType.StringAxis ? 0 : yBarScale(Y_ORIGIN));
752
776
  let yPositiveStart = yBaseline;
753
777
  let yNegativeStart = yBaseline;
754
778
  let yPoint = 0;
@@ -757,7 +781,7 @@ const VerticalStackedBarChart = (props)=>{
757
781
  const startColor = point.color ? point.color : _colors[index];
758
782
  const ref = {};
759
783
  const shouldHighlight = _isLegendHighlighted(point.legend) || _noLegendHighlighted() ? true : false;
760
- const rectFocusProps = !shouldFocusWholeStack && {
784
+ const rectFocusProps = !shouldFocusWholeStack && shouldHighlight && {
761
785
  'aria-label': _getAriaLabel(singleChartData, point),
762
786
  onMouseOver: (event)=>_onRectHover(singleChartData.xAxisPoint, point, startColor, event),
763
787
  onMouseMove: (event)=>_onRectHover(singleChartData.xAxisPoint, point, startColor, event),
@@ -768,22 +792,29 @@ const VerticalStackedBarChart = (props)=>{
768
792
  role: 'img',
769
793
  tabIndex: !props.hideTooltip && shouldHighlight ? 0 : undefined
770
794
  };
771
- let barHeight = Math.abs(heightValueScale * point.data);
772
- // FIXME: The current scaling logic may produce different min and gap heights for each bar stack.
773
- const minHeight = Math.max(heightValueScale * absStackTotal / 100.0, barMinimumHeight);
774
- if (barHeight < minHeight) {
775
- barHeight = minHeight;
776
- }
795
+ let barHeight;
777
796
  const gapOffset = index ? gapHeight : 0;
778
- if (point.data >= Y_ORIGIN) {
797
+ if (_yAxisType === _index1.YAxisType.StringAxis) {
798
+ barHeight = Math.max(containerHeight - _margins.bottom - (yBarScale(point.data) + yBarScale.bandwidth() / 2) - gapOffset, barMinimumHeight, 1);
779
799
  yPositiveStart -= barHeight + gapOffset;
780
800
  yPoint = yPositiveStart;
781
801
  } else {
782
- yPoint = yNegativeStart + gapOffset;
783
- yNegativeStart = yPoint + barHeight;
802
+ barHeight = Math.abs(heightValueScale * point.data);
803
+ // FIXME: The current scaling logic may produce different min and gap heights for each bar stack.
804
+ const minHeight = Math.max(heightValueScale * absStackTotal / 100.0, barMinimumHeight);
805
+ if (barHeight < minHeight) {
806
+ barHeight = minHeight;
807
+ }
808
+ if (point.data >= Y_ORIGIN) {
809
+ yPositiveStart -= barHeight + gapOffset;
810
+ yPoint = yPositiveStart;
811
+ } else {
812
+ yPoint = yNegativeStart + gapOffset;
813
+ yNegativeStart = yPoint + barHeight;
814
+ }
815
+ barTotalValue += point.data;
816
+ heightOfLastBar = index === barsToDisplay.length - 1 ? barHeight : 0;
784
817
  }
785
- barTotalValue += point.data;
786
- heightOfLastBar = index === barsToDisplay.length - 1 ? barHeight : 0;
787
818
  if (barCornerRadius && barHeight > barCornerRadius && index === barsToDisplay.length - 1) {
788
819
  return /*#__PURE__*/ _react.createElement(_react.Fragment, {
789
820
  key: index + indexNumber + `${shouldFocusWholeStack}`
@@ -829,7 +860,11 @@ const VerticalStackedBarChart = (props)=>{
829
860
  }));
830
861
  });
831
862
  const groupRef = {};
832
- const stackFocusProps = shouldFocusWholeStack && {
863
+ const someBarsActive = singleChartData.chartData.filter((dataPoint)=>_noLegendHighlighted() || _isLegendHighlighted(dataPoint.legend)).length > 0;
864
+ // FIXME: Making the entire stack focusable when stack callout is enabled adds unnecessary complexity
865
+ // and can reduce usability in certain scenarios. Instead, each individual element within the stack
866
+ // should be focusable on its own, with its own aria-label. This behavior is also seen in Highcharts.
867
+ const stackFocusProps = shouldFocusWholeStack && someBarsActive && {
833
868
  'aria-label': _getAriaLabel(singleChartData),
834
869
  onMouseOver: (event)=>_onStackHover(singleChartData, event),
835
870
  onMouseMove: (event)=>_onStackHover(singleChartData, event),
@@ -842,7 +877,7 @@ const VerticalStackedBarChart = (props)=>{
842
877
  };
843
878
  let showLabel = false;
844
879
  let barLabel = 0;
845
- if (!props.hideLabels) {
880
+ if (!props.hideLabels && _yAxisType !== _index1.YAxisType.StringAxis) {
846
881
  if (_noLegendHighlighted()) {
847
882
  showLabel = true;
848
883
  barLabel = barTotalValue;
@@ -912,6 +947,83 @@ const VerticalStackedBarChart = (props)=>{
912
947
  endValue: (0, _d3array.max)(values)
913
948
  };
914
949
  }
950
+ function _initYAxisParams() {
951
+ if (_points[0].chartData.length > 0) {
952
+ _yAxisType = (0, _index1.getTypeOfAxis)(_points[0].chartData[0].data, false);
953
+ } else {
954
+ Object.keys(_lineObject).forEach((lineLegend)=>{
955
+ if (!_lineObject[lineLegend][0].useSecondaryYScale) {
956
+ _yAxisType = (0, _index1.getTypeOfAxis)(_lineObject[lineLegend][0].y, false);
957
+ }
958
+ });
959
+ }
960
+ _yAxisLabels = _getOrderedYAxisLabels();
961
+ }
962
+ function _getYDomainMargins(containerHeight) {
963
+ /**
964
+ * Specifies the extra top margin to apply above the highest y-axis tick label.
965
+ * Useful when stacked bars extend beyond the combined height of all y-axis labels (or categories).
966
+ */ let yAxisTickMarginTop = 0;
967
+ /** Total height available to render the bars */ const totalHeight = containerHeight - _margins.bottom - _margins.top;
968
+ if (_yAxisType === _index1.YAxisType.StringAxis) {
969
+ /** Maximum height of the stacked bars, expressed in multiples of the height of a y-axis label (or category) */ let maxBarHeightInLabels = 0;
970
+ _points.forEach((xPoint)=>{
971
+ /** Height of the stacked bar, expressed in multiples of the height of a y-axis label (or category) */ let barHeightInLabels = 0;
972
+ xPoint.chartData.forEach((bar)=>{
973
+ barHeightInLabels += _yAxisLabels.indexOf(`${bar.data}`) + 1;
974
+ });
975
+ maxBarHeightInLabels = Math.max(maxBarHeightInLabels, barHeightInLabels);
976
+ });
977
+ /** Height of a y-axis label (or category) */ const yAxisLabelHeight = maxBarHeightInLabels === 0 ? 0 : totalHeight / maxBarHeightInLabels;
978
+ yAxisTickMarginTop += yAxisLabelHeight * (maxBarHeightInLabels - _yAxisLabels.length);
979
+ }
980
+ return {
981
+ ..._margins,
982
+ top: _margins.top + yAxisTickMarginTop
983
+ };
984
+ }
985
+ function _getOrderedXAxisLabels() {
986
+ if (_xAxisType !== _index1.XAxisTypes.StringAxis) {
987
+ return [];
988
+ }
989
+ return (0, _index1.sortAxisCategories)(_mapCategoryToValues(), props.xAxisCategoryOrder);
990
+ }
991
+ function _getOrderedYAxisLabels() {
992
+ if (_yAxisType !== _index1.YAxisType.StringAxis) {
993
+ return [];
994
+ }
995
+ return (0, _index1.sortAxisCategories)(_mapCategoryToValues(true), props.yAxisCategoryOrder);
996
+ }
997
+ function _mapCategoryToValues(isYAxis = false) {
998
+ const categoryToValues = {};
999
+ _points.forEach((point)=>{
1000
+ var _point_lineData;
1001
+ point.chartData.forEach((bar)=>{
1002
+ const category = isYAxis ? bar.data : point.xAxisPoint;
1003
+ const value = isYAxis ? point.xAxisPoint : bar.data;
1004
+ if (!categoryToValues[category]) {
1005
+ categoryToValues[category] = [];
1006
+ }
1007
+ if (typeof value === 'number') {
1008
+ categoryToValues[category].push(value);
1009
+ }
1010
+ });
1011
+ (_point_lineData = point.lineData) === null || _point_lineData === void 0 ? void 0 : _point_lineData.forEach((linePoint)=>{
1012
+ if (isYAxis && linePoint.useSecondaryYScale) {
1013
+ return;
1014
+ }
1015
+ const category = isYAxis ? linePoint.y : point.xAxisPoint;
1016
+ const value = isYAxis ? point.xAxisPoint : linePoint.y;
1017
+ if (!categoryToValues[category]) {
1018
+ categoryToValues[category] = [];
1019
+ }
1020
+ if (typeof value === 'number') {
1021
+ categoryToValues[category].push(value);
1022
+ }
1023
+ });
1024
+ });
1025
+ return categoryToValues;
1026
+ }
915
1027
  if (!_isChartEmpty()) {
916
1028
  _adjustProps();
917
1029
  const _isHavingLines = props.data.some((item)=>item.lineData && item.lineData.length > 0);
@@ -967,6 +1079,12 @@ const VerticalStackedBarChart = (props)=>{
967
1079
  },
968
1080
  componentRef: cartesianChartRef,
969
1081
  showRoundOffXTickValues: !(0, _index1.isScalePaddingDefined)(props.xAxisInnerPadding, props.xAxisPadding),
1082
+ yAxisType: _yAxisType,
1083
+ stringDatasetForYAxisDomain: [
1084
+ '',
1085
+ ..._yAxisLabels
1086
+ ],
1087
+ getYDomainMargins: _getYDomainMargins,
970
1088
  /* eslint-disable react/jsx-no-bind */ children: (props)=>{
971
1089
  return /*#__PURE__*/ _react.createElement(_react.Fragment, null, /*#__PURE__*/ _react.createElement("g", null, _bars), /*#__PURE__*/ _react.createElement("g", null, _isHavingLines && _createLines(props.xScale, props.yScalePrimary, props.containerHeight, props.containerWidth, props.yScaleSecondary)));
972
1090
  }
@@ -980,5 +1098,5 @@ const VerticalStackedBarChart = (props)=>{
980
1098
  },
981
1099
  "aria-label": 'Graph has no data to display'
982
1100
  });
983
- };
1101
+ });
984
1102
  VerticalStackedBarChart.displayName = 'VerticalStackedBarChart';