@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
@@ -6,17 +6,17 @@ import { scaleLinear as d3ScaleLinear, scaleBand as d3ScaleBand, scaleUtc as d3S
6
6
  import { useId } from '@fluentui/react-utilities';
7
7
  import { tokens } from '@fluentui/react-theme';
8
8
  import { CartesianChart, ChartPopover, Legends } from '../../index';
9
- import { ChartTypes, getAccessibleDataObject, XAxisTypes, getTypeOfAxis, tooltipOfAxislabels, formatScientificLimitWidth, getBarWidth, getScalePadding, isScalePaddingDefined, calculateAppropriateBarWidth, formatDate, areArraysEqual, calculateLongestLabelWidth, useRtl, DataVizPalette, getColorFromToken, findVSBCNumericMinMaxOfY, createNumericYAxis, domainRangeOfDateForAreaLineVerticalBarChart, domainRangeOfVSBCNumeric, domainRangeOfXStringAxis, createStringYAxis } from '../../utilities/index';
9
+ import { ChartTypes, getAccessibleDataObject, XAxisTypes, getTypeOfAxis, tooltipOfAxislabels, formatScientificLimitWidth, getBarWidth, getScalePadding, isScalePaddingDefined, calculateAppropriateBarWidth, formatDate, areArraysEqual, calculateLongestLabelWidth, useRtl, DataVizPalette, getColorFromToken, findVSBCNumericMinMaxOfY, YAxisType, createNumericYAxis, domainRangeOfDateForAreaLineVerticalBarChart, domainRangeOfVSBCNumeric, domainRangeOfXStringAxis, createStringYAxis, calcTotalWidth, calcBandwidth, calcRequiredWidth, sortAxisCategories } from '../../utilities/index';
10
10
  import { toImage } from '../../utilities/image-export-utils';
11
+ import { formatDateToLocaleString } from '@fluentui/chart-utilities';
11
12
  const barGapMultiplier = 0.2;
12
13
  const barGapMin = 1;
13
14
  const MIN_DOMAIN_MARGIN = 8;
14
- var CircleVisbility = /*#__PURE__*/ function(CircleVisbility) {
15
- CircleVisbility["show"] = "visibility";
16
- CircleVisbility["hide"] = "hidden";
17
- return CircleVisbility;
18
- }(CircleVisbility || {});
19
- export const VerticalStackedBarChart = (props)=>{
15
+ export const VerticalStackedBarChart = /*#__PURE__*/ React.forwardRef((props = {
16
+ xAxisCategoryOrder: 'default',
17
+ yAxisCategoryOrder: 'default',
18
+ data: []
19
+ }, forwardedRef)=>{
20
20
  var _props_legendProps;
21
21
  const _isRtl = useRtl();
22
22
  const _createLegendsForLine = (data)=>_getLineLegends(data);
@@ -40,6 +40,8 @@ export const VerticalStackedBarChart = (props)=>{
40
40
  const cartesianChartRef = React.useRef(null);
41
41
  const Y_ORIGIN = 0;
42
42
  const _legendsRef = React.useRef(null);
43
+ let _yAxisType;
44
+ let _yAxisLabels = [];
43
45
  const [selectedLegends, setSelectedLegends] = React.useState(((_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.selectedLegends) || []);
44
46
  const [activeLegend, setActiveLegend] = React.useState(undefined);
45
47
  const [dataForHoverCard, setDataForHoverCard] = React.useState(0);
@@ -150,19 +152,29 @@ export const VerticalStackedBarChart = (props)=>{
150
152
  activeLegend
151
153
  ] : [];
152
154
  }
153
- function _lineHoverOut() {
154
- setPopoverOpen(false);
155
- setXCalloutValue('');
156
- setYCalloutValue('');
157
- setActiveXAxisDataPoint('');
158
- setColor('');
159
- }
160
- function _lineHoverFocus(lineData) {
161
- setPopoverOpen(true);
162
- setXCalloutValue(`${lineData.xItem.xAxisPoint}`);
163
- setYCalloutValue(`${lineData.yAxisCalloutData || lineData.data || lineData.y}`);
164
- setActiveXAxisDataPoint(lineData.xItem.xAxisPoint);
165
- setColor(lineData.color);
155
+ function _lineHoverFocus(lineData, event) {
156
+ let clientX = 0;
157
+ let clientY = 0;
158
+ if ('clientX' in event) {
159
+ clientX = event.clientX;
160
+ clientY = event.clientY;
161
+ } else {
162
+ const boundingRect = event.target.getBoundingClientRect();
163
+ clientX = boundingRect.left + boundingRect.width / 2;
164
+ clientY = boundingRect.top + boundingRect.height / 2;
165
+ }
166
+ if (_getHighlightedLegend().length === 1) {
167
+ if (_noLegendHighlighted() || _isLegendHighlighted(lineData.legend)) {
168
+ _updatePosition(clientX, clientY);
169
+ setPopoverOpen(true);
170
+ setXCalloutValue(`${lineData.xItem.xAxisPoint}`);
171
+ setYCalloutValue(`${lineData.yAxisCalloutData || lineData.data || lineData.y}`);
172
+ setActiveXAxisDataPoint(lineData.xItem.xAxisPoint);
173
+ setColor(lineData.color);
174
+ }
175
+ } else {
176
+ _onStackHoverFocus(lineData.xItem, event);
177
+ }
166
178
  }
167
179
  function _onStackHoverFocus(stack, mouseEvent) {
168
180
  var _stack_lineData;
@@ -230,21 +242,26 @@ export const VerticalStackedBarChart = (props)=>{
230
242
  _lineObject = _getFormattedLineData(props.data);
231
243
  _xAxisInnerPadding = getScalePadding(props.xAxisInnerPadding, props.xAxisPadding, _xAxisType === XAxisTypes.StringAxis ? 2 / 3 : 1 / 2);
232
244
  _xAxisOuterPadding = getScalePadding(props.xAxisOuterPadding, props.xAxisPadding, 0);
245
+ _initYAxisParams();
233
246
  }
234
247
  function _createDataSetLayer() {
235
- const tempArr = [];
236
248
  const dataset = _points.map((singlePointData)=>{
249
+ if (_yAxisType === YAxisType.StringAxis) {
250
+ return {
251
+ x: singlePointData.xAxisPoint,
252
+ y: 0
253
+ };
254
+ }
237
255
  let total = 0;
238
256
  singlePointData.chartData.forEach((point)=>{
239
257
  total = total + point.data;
240
258
  });
241
- tempArr.push(singlePointData.xAxisPoint);
242
259
  return {
243
260
  x: singlePointData.xAxisPoint,
244
261
  y: total
245
262
  };
246
263
  });
247
- _xAxisLabels = tempArr;
264
+ _xAxisLabels = _getOrderedXAxisLabels();
248
265
  return dataset;
249
266
  }
250
267
  function _onLegendHover(legendTitle) {
@@ -269,7 +286,7 @@ export const VerticalStackedBarChart = (props)=>{
269
286
  }
270
287
  function _getGraphData(xScale, yScale, containerHeight, containerWidth, xElement) {
271
288
  const { xBarScale, yBarScale } = _getScales(containerHeight, containerWidth);
272
- return _bars = _createBar(xBarScale, yBarScale, containerHeight, xElement);
289
+ return _bars = _createBar(xBarScale, _yAxisType === YAxisType.StringAxis ? yScale : yBarScale, containerHeight, xElement);
273
290
  }
274
291
  function _getAxisData(yAxisData) {
275
292
  if (yAxisData && yAxisData.yAxisDomainValues.length) {
@@ -279,19 +296,19 @@ export const VerticalStackedBarChart = (props)=>{
279
296
  }
280
297
  }
281
298
  /**
282
- * This function checks if the given legend is highlighted or not.
283
- * A legend can be highlighted in 2 ways:
284
- * 1. selection: if the user clicks on it
285
- * 2. hovering: if there is no selected legend and the user hovers over it
286
- */ function _isLegendHighlighted(legendTitle) {
299
+ * This function checks if the given legend is highlighted or not.
300
+ * A legend can be highlighted in 2 ways:
301
+ * 1. selection: if the user clicks on it
302
+ * 2. hovering: if there is no selected legend and the user hovers over it
303
+ */ function _isLegendHighlighted(legendTitle) {
287
304
  return _getHighlightedLegend().includes(legendTitle);
288
305
  }
289
306
  /**
290
- * This function checks if none of the legends is selected or hovered.
291
- */ function _noLegendHighlighted() {
307
+ * This function checks if none of the legends is selected or hovered.
308
+ */ function _noLegendHighlighted() {
292
309
  return _getHighlightedLegend().length === 0;
293
310
  }
294
- function _getAriaLabel(singleChartData, point) {
311
+ function _getAriaLabel(singleChartData, point, isLinePoint) {
295
312
  var _point_callOutAccessibilityData;
296
313
  if (!point) {
297
314
  var _singleChartData_lineData, _singleChartData_stackCallOutAccessibilityData;
@@ -299,19 +316,19 @@ export const VerticalStackedBarChart = (props)=>{
299
316
  const pointValues = singleChartData.chartData.map((pt)=>{
300
317
  const legend = pt.legend;
301
318
  const yValue = pt.yAxisCalloutData || pt.data;
302
- return `${legend}, ${yValue}.`;
303
- }).join(' ');
319
+ return _noLegendHighlighted() || _isLegendHighlighted(legend) ? `${legend}, ${yValue}.` : '';
320
+ }).filter((str)=>str !== '').join(' ');
304
321
  const lineValues = (_singleChartData_lineData = singleChartData.lineData) === null || _singleChartData_lineData === void 0 ? void 0 : _singleChartData_lineData.map((ln)=>{
305
322
  const legend = ln.legend;
306
323
  const yValue = ln.yAxisCalloutData || ln.data || ln.y;
307
- return `${legend}, ${yValue}.`;
308
- }).join(' ');
324
+ return _noLegendHighlighted() || _isLegendHighlighted(legend) ? `${legend}, ${yValue}.` : '';
325
+ }).filter((str)=>str !== '').join(' ');
309
326
  return ((_singleChartData_stackCallOutAccessibilityData = singleChartData.stackCallOutAccessibilityData) === null || _singleChartData_stackCallOutAccessibilityData === void 0 ? void 0 : _singleChartData_stackCallOutAccessibilityData.ariaLabel) || `${xValue}. ${pointValues}` + (lineValues ? ` ${lineValues}` : '');
310
327
  }
311
- /** if shouldFocusWholeStack is false */ const xValue = singleChartData.xAxisCalloutData || point.xAxisCalloutData || (singleChartData.xAxisPoint instanceof Date ? formatDate(singleChartData.xAxisPoint) : singleChartData.xAxisPoint);
328
+ /** if shouldFocusWholeStack is false */ const xValue = singleChartData.xAxisCalloutData || !isLinePoint && point.xAxisCalloutData || (singleChartData.xAxisPoint instanceof Date ? formatDate(singleChartData.xAxisPoint) : singleChartData.xAxisPoint);
312
329
  const legend = point.legend;
313
- const yValue = point.yAxisCalloutData || point.data;
314
- return ((_point_callOutAccessibilityData = point.callOutAccessibilityData) === null || _point_callOutAccessibilityData === void 0 ? void 0 : _point_callOutAccessibilityData.ariaLabel) || `${xValue}. ${legend}, ${yValue}.`;
330
+ const yValue = point.yAxisCalloutData || (isLinePoint ? point.data || point.y : point.data);
331
+ return !isLinePoint && ((_point_callOutAccessibilityData = point.callOutAccessibilityData) === null || _point_callOutAccessibilityData === void 0 ? void 0 : _point_callOutAccessibilityData.ariaLabel) || `${xValue}. ${legend}, ${yValue}.`;
315
332
  }
316
333
  function _getCustomizedCallout() {
317
334
  const _isHavingLines = props.data.some((item)=>item.lineData && item.lineData.length > 0);
@@ -396,6 +413,7 @@ export const VerticalStackedBarChart = (props)=>{
396
413
  const y1 = useSecondaryYScale ? yScaleSecondary(lineObject[item][i - 1].y) : yScalePrimary(lineObject[item][i - 1].y);
397
414
  const x2 = xScale(lineObject[item][i].xItem.xAxisPoint);
398
415
  const y2 = useSecondaryYScale ? yScaleSecondary(lineObject[item][i].y) : yScalePrimary(lineObject[item][i].y);
416
+ const yScaleBandwidthTranslate = !useSecondaryYScale && _yAxisType === YAxisType.StringAxis ? yScalePrimary.bandwidth() / 2 : 0;
399
417
  if (lineBorderWidth > 0) {
400
418
  borderForLines.push(/*#__PURE__*/ React.createElement("line", {
401
419
  key: `${index}-${i}-BorderLine`,
@@ -408,7 +426,7 @@ export const VerticalStackedBarChart = (props)=>{
408
426
  fill: "transparent",
409
427
  strokeLinecap: "round",
410
428
  stroke: tokens.colorNeutralBackground1,
411
- transform: `translate(${xScaleBandwidthTranslate}, 0)`
429
+ transform: `translate(${xScaleBandwidthTranslate}, ${yScaleBandwidthTranslate})`
412
430
  }));
413
431
  }
414
432
  var _lineObject_item__lineOptions_strokeWidth, _lineObject_item__lineOptions_strokeLinecap;
@@ -423,11 +441,9 @@ export const VerticalStackedBarChart = (props)=>{
423
441
  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',
424
442
  strokeDasharray: (_lineObject_item__lineOptions2 = lineObject[item][0].lineOptions) === null || _lineObject_item__lineOptions2 === void 0 ? void 0 : _lineObject_item__lineOptions2.strokeDasharray,
425
443
  stroke: lineObject[item][i].color,
426
- transform: `translate(${xScaleBandwidthTranslate}, 0)`,
427
- ..._isLegendHighlighted(item) && {
428
- onMouseOver: _lineHover.bind(lineObject[item][i - 1]),
429
- onMouseLeave: _lineHoverOut
430
- }
444
+ transform: `translate(${xScaleBandwidthTranslate}, ${yScaleBandwidthTranslate})`,
445
+ onMouseOver: (event)=>_lineHover(lineObject[item][i - 1], event),
446
+ onMouseLeave: _handleMouseOut
431
447
  }));
432
448
  }
433
449
  });
@@ -437,20 +453,21 @@ export const VerticalStackedBarChart = (props)=>{
437
453
  refElement: null
438
454
  };
439
455
  const noBarsAndLinesActive = circlePoint.xItem.chartData.filter((dataPoint)=>_noLegendHighlighted() || _isLegendHighlighted(dataPoint.legend)).length === 0;
456
+ const yScaleBandwidthTranslate = !circlePoint.useSecondaryYScale && _yAxisType === YAxisType.StringAxis ? yScalePrimary.bandwidth() / 2 : 0;
440
457
  dots.push(/*#__PURE__*/ React.createElement("circle", {
441
458
  key: `${index}-${subIndex}-dot`,
442
459
  cx: xScale(circlePoint.xItem.xAxisPoint),
443
460
  cy: circlePoint.useSecondaryYScale && yScaleSecondary ? yScaleSecondary(circlePoint.y) : yScalePrimary(circlePoint.y),
444
- onMouseOver: _isLegendHighlighted(item) ? (event)=>_lineHover(circlePoint, event) : (event)=>_onStackHover(circlePoint.xItem, event),
445
- ..._isLegendHighlighted(item) && {
446
- onMouseLeave: _lineHoverOut
447
- },
448
- r: _getCircleVisibilityAndRadius(circlePoint.xItem.xAxisPoint, circlePoint.legend).radius,
461
+ onMouseOver: (event)=>_lineHover(circlePoint, event),
462
+ onMouseLeave: _handleMouseOut,
463
+ r: _getCircleOpacityAndRadius(circlePoint.xItem.xAxisPoint, circlePoint.legend).radius,
449
464
  stroke: circlePoint.color,
450
465
  fill: tokens.colorNeutralBackground1,
451
466
  strokeWidth: 3,
452
- visibility: _getCircleVisibilityAndRadius(circlePoint.xItem.xAxisPoint, circlePoint.legend).visibility,
453
- transform: `translate(${xScaleBandwidthTranslate}, 0)`,
467
+ // Elements with visibility: hidden cannot receive focus, so use opacity: 0 instead to hide them.
468
+ // For more information, see https://fuzzbomb.github.io/accessibility-demos/visually-hidden-focus-test.html
469
+ opacity: _getCircleOpacityAndRadius(circlePoint.xItem.xAxisPoint, circlePoint.legend).opacity,
470
+ transform: `translate(${xScaleBandwidthTranslate}, ${yScaleBandwidthTranslate})`,
454
471
  ref: (e)=>circleRef.refElement = e,
455
472
  ...noBarsAndLinesActive ? {
456
473
  tabIndex: !props.hideTooltip ? 0 : undefined,
@@ -464,27 +481,27 @@ export const VerticalStackedBarChart = (props)=>{
464
481
  });
465
482
  return /*#__PURE__*/ React.createElement(React.Fragment, null, borderForLines, lines, dots);
466
483
  }
467
- function _getCircleVisibilityAndRadius(xAxisPoint, legend) {
484
+ function _getCircleOpacityAndRadius(xAxisPoint, legend) {
468
485
  if (!_noLegendHighlighted()) {
469
486
  if (xAxisPoint === activeXAxisDataPoint && _isLegendHighlighted(legend)) {
470
487
  return {
471
- visibility: "visibility",
488
+ opacity: 1,
472
489
  radius: 8
473
490
  };
474
491
  } else if (_isLegendHighlighted(legend)) {
475
492
  return {
476
- visibility: "visibility",
493
+ opacity: 1,
477
494
  radius: 0.3
478
495
  };
479
496
  } else {
480
497
  return {
481
- visibility: "hidden",
498
+ opacity: 0,
482
499
  radius: 0
483
500
  };
484
501
  }
485
502
  } else {
486
503
  return {
487
- visibility: activeXAxisDataPoint === xAxisPoint ? "visibility" : "hidden",
504
+ opacity: activeXAxisDataPoint === xAxisPoint ? 1 : 0,
488
505
  radius: 8
489
506
  };
490
507
  }
@@ -522,14 +539,15 @@ export const VerticalStackedBarChart = (props)=>{
522
539
  if ((_calloutAnchorPoint === null || _calloutAnchorPoint === void 0 ? void 0 : _calloutAnchorPoint.chartDataPoint) !== point || (_calloutAnchorPoint === null || _calloutAnchorPoint === void 0 ? void 0 : _calloutAnchorPoint.xAxisDataPoint) !== xAxisPoint) {
523
540
  _calloutAnchorPoint = {
524
541
  chartDataPoint: point,
525
- xAxisDataPoint: `${xAxisPoint}`
542
+ xAxisDataPoint: xAxisPoint instanceof Date ? formatDateToLocaleString(xAxisPoint, props.culture, props.useUTC) : xAxisPoint.toString()
526
543
  };
544
+ const xCalloutValue = point.xAxisCalloutData || (xAxisPoint instanceof Date ? formatDateToLocaleString(xAxisPoint, props.culture, props.useUTC) : xAxisPoint.toString());
527
545
  _updatePosition(clientX, clientY);
528
546
  setPopoverOpen(_noLegendHighlighted() || _isLegendHighlighted(point.legend));
529
547
  setCalloutLegend(point.legend);
530
548
  setDataForHoverCard(point.data);
531
549
  setColor(color);
532
- setXCalloutValue(point.xAxisCalloutData ? point.xAxisCalloutData : `${xAxisPoint}`);
550
+ setXCalloutValue(xCalloutValue);
533
551
  setYCalloutValue(point.yAxisCalloutData);
534
552
  setDataPointCalloutProps(point);
535
553
  setCallOutAccessibilityData(point.callOutAccessibilityData);
@@ -537,11 +555,11 @@ export const VerticalStackedBarChart = (props)=>{
537
555
  }
538
556
  function _lineHover(lineData, mouseEvent) {
539
557
  mouseEvent.persist();
540
- _lineHoverFocus(lineData);
558
+ _lineHoverFocus(lineData, mouseEvent);
541
559
  }
542
560
  function _lineFocus(event, lineData, ref) {
543
561
  if (ref.refElement) {
544
- _lineHoverFocus(lineData);
562
+ _lineHoverFocus(lineData, event);
545
563
  }
546
564
  }
547
565
  function _onStackHover(stack, mouseEvent) {
@@ -563,22 +581,29 @@ export const VerticalStackedBarChart = (props)=>{
563
581
  }
564
582
  function _getBarGapAndScale(bars, yBarScale, defaultTotalHeight) {
565
583
  const { barGapMax = 0 } = props;
566
- // When displaying gaps between the bars, the height of each bar is
567
- // adjusted so that the total of all bars is not changed by the gaps
568
- const totalData = bars.reduce((iter, value)=>iter + Math.abs(value.data), 0);
569
- const totalHeight = defaultTotalHeight !== null && defaultTotalHeight !== void 0 ? defaultTotalHeight : Math.abs(yBarScale(totalData) - yBarScale(Y_ORIGIN));
584
+ let totalData = 0;
585
+ let totalHeight;
570
586
  let sumOfPercent = 0;
571
- bars.forEach((point)=>{
572
- let value = Math.abs(point.data) / totalData * 100;
573
- if (value < 1 && value !== 0) {
574
- value = 1;
575
- }
576
- sumOfPercent += value;
577
- });
578
- const scalingRatio = sumOfPercent !== 0 ? sumOfPercent / 100 : 1;
587
+ let scalingRatio;
588
+ if (_yAxisType === YAxisType.StringAxis) {
589
+ totalHeight = defaultTotalHeight !== null && defaultTotalHeight !== void 0 ? defaultTotalHeight : bars.reduce((total, bar)=>total + yBarScale(bar.data), 0);
590
+ } else {
591
+ // When displaying gaps between the bars, the height of each bar is
592
+ // adjusted so that the total of all bars is not changed by the gaps
593
+ totalData = bars.reduce((iter, value)=>iter + Math.abs(value.data), 0);
594
+ totalHeight = defaultTotalHeight !== null && defaultTotalHeight !== void 0 ? defaultTotalHeight : Math.abs(yBarScale(totalData) - yBarScale(Y_ORIGIN));
595
+ bars.forEach((point)=>{
596
+ let value = Math.abs(point.data) / totalData * 100;
597
+ if (value < 1 && value !== 0) {
598
+ value = 1;
599
+ }
600
+ sumOfPercent += value;
601
+ });
602
+ scalingRatio = sumOfPercent !== 0 ? sumOfPercent / 100 : 1;
603
+ }
579
604
  const gaps = barGapMax && bars.length - 1;
580
605
  const gapHeight = gaps && Math.max(barGapMin, Math.min(barGapMax, totalHeight * barGapMultiplier / gaps));
581
- const heightValueScale = (totalHeight - gapHeight * gaps) / (totalData * scalingRatio);
606
+ const heightValueScale = _yAxisType === YAxisType.StringAxis ? 0 : (totalHeight - gapHeight * gaps) / (totalData * scalingRatio);
582
607
  return {
583
608
  gapHeight,
584
609
  heightValueScale,
@@ -669,8 +694,7 @@ export const VerticalStackedBarChart = (props)=>{
669
694
  }
670
695
  function _getDomainMargins(containerWidth) {
671
696
  _domainMargin = MIN_DOMAIN_MARGIN;
672
- /** Total width available to render the bars */ const totalWidth = containerWidth - (_margins.left + MIN_DOMAIN_MARGIN) - (_margins.right + MIN_DOMAIN_MARGIN);
673
- /** Rate at which the space between the bars changes wrt the bar width */ const barGapRate = _xAxisInnerPadding / (1 - _xAxisInnerPadding);
697
+ const totalWidth = calcTotalWidth(containerWidth, _margins, MIN_DOMAIN_MARGIN);
674
698
  if (_xAxisType === XAxisTypes.StringAxis) {
675
699
  if (isScalePaddingDefined(props.xAxisOuterPadding, props.xAxisPadding)) {
676
700
  // Setting the domain margin for string x-axis to 0 because the xAxisOuterPadding prop is now available
@@ -680,16 +704,16 @@ export const VerticalStackedBarChart = (props)=>{
680
704
  // Update the bar width so that when CartesianChart rerenders,
681
705
  // the following calculations don't use the previous bar width.
682
706
  _barWidth = getBarWidth(props.barWidth, props.maxBarWidth);
683
- /** Total width required to render the bars. Directly proportional to bar width */ const reqWidth = (_xAxisLabels.length + (_xAxisLabels.length - 1) * barGapRate) * _barWidth;
707
+ /** Total width required to render the bars. Directly proportional to bar width */ const reqWidth = calcRequiredWidth(_barWidth, _xAxisLabels.length, _xAxisInnerPadding);
684
708
  if (totalWidth >= reqWidth) {
685
709
  // Center align the chart by setting equal left and right margins for domain
686
710
  _domainMargin = MIN_DOMAIN_MARGIN + (totalWidth - reqWidth) / 2;
687
711
  }
688
712
  } else if (props.mode === 'plotly' && _xAxisLabels.length > 1) {
689
713
  // Calculate the remaining width after rendering bars at their maximum allowable width
690
- const bandwidth = totalWidth / (_xAxisLabels.length + (_xAxisLabels.length - 1) * barGapRate);
714
+ const bandwidth = calcBandwidth(totalWidth, _xAxisLabels.length, _xAxisInnerPadding);
691
715
  const barWidth = getBarWidth(props.barWidth, props.maxBarWidth, bandwidth);
692
- let reqWidth = (_xAxisLabels.length + (_xAxisLabels.length - 1) * barGapRate) * barWidth;
716
+ let reqWidth = calcRequiredWidth(barWidth, _xAxisLabels.length, _xAxisInnerPadding);
693
717
  const margin1 = (totalWidth - reqWidth) / 2;
694
718
  let margin2 = Number.POSITIVE_INFINITY;
695
719
  if (!props.hideTickOverlap) {
@@ -729,7 +753,7 @@ export const VerticalStackedBarChart = (props)=>{
729
753
  const xPoint = xBarScale(_xAxisType === XAxisTypes.NumericAxis ? singleChartData.xAxisPoint : _xAxisType === XAxisTypes.DateAxis ? singleChartData.xAxisPoint : singleChartData.xAxisPoint);
730
754
  const xScaleBandwidthTranslate = _xAxisType !== XAxisTypes.StringAxis ? -_barWidth / 2 : (xBarScale.bandwidth() - _barWidth) / 2;
731
755
  let barTotalValue = 0;
732
- const barsToDisplay = singleChartData.chartData.filter((point)=>point.data !== 0);
756
+ const barsToDisplay = singleChartData.chartData.filter((point)=>point.data !== 0 && point.data !== '' && !(_yAxisType === YAxisType.StringAxis && typeof yBarScale(point.data) === 'undefined'));
733
757
  if (!barsToDisplay.length) {
734
758
  return undefined;
735
759
  }
@@ -737,7 +761,7 @@ export const VerticalStackedBarChart = (props)=>{
737
761
  if (heightValueScale < 0) {
738
762
  return undefined;
739
763
  }
740
- const yBaseline = containerHeight - _margins.bottom - yBarScale(Y_ORIGIN);
764
+ const yBaseline = containerHeight - _margins.bottom - (_yAxisType === YAxisType.StringAxis ? 0 : yBarScale(Y_ORIGIN));
741
765
  let yPositiveStart = yBaseline;
742
766
  let yNegativeStart = yBaseline;
743
767
  let yPoint = 0;
@@ -746,7 +770,7 @@ export const VerticalStackedBarChart = (props)=>{
746
770
  const startColor = point.color ? point.color : _colors[index];
747
771
  const ref = {};
748
772
  const shouldHighlight = _isLegendHighlighted(point.legend) || _noLegendHighlighted() ? true : false;
749
- const rectFocusProps = !shouldFocusWholeStack && {
773
+ const rectFocusProps = !shouldFocusWholeStack && shouldHighlight && {
750
774
  'aria-label': _getAriaLabel(singleChartData, point),
751
775
  onMouseOver: (event)=>_onRectHover(singleChartData.xAxisPoint, point, startColor, event),
752
776
  onMouseMove: (event)=>_onRectHover(singleChartData.xAxisPoint, point, startColor, event),
@@ -757,22 +781,29 @@ export const VerticalStackedBarChart = (props)=>{
757
781
  role: 'img',
758
782
  tabIndex: !props.hideTooltip && shouldHighlight ? 0 : undefined
759
783
  };
760
- let barHeight = Math.abs(heightValueScale * point.data);
761
- // FIXME: The current scaling logic may produce different min and gap heights for each bar stack.
762
- const minHeight = Math.max(heightValueScale * absStackTotal / 100.0, barMinimumHeight);
763
- if (barHeight < minHeight) {
764
- barHeight = minHeight;
765
- }
784
+ let barHeight;
766
785
  const gapOffset = index ? gapHeight : 0;
767
- if (point.data >= Y_ORIGIN) {
786
+ if (_yAxisType === YAxisType.StringAxis) {
787
+ barHeight = Math.max(containerHeight - _margins.bottom - (yBarScale(point.data) + yBarScale.bandwidth() / 2) - gapOffset, barMinimumHeight, 1);
768
788
  yPositiveStart -= barHeight + gapOffset;
769
789
  yPoint = yPositiveStart;
770
790
  } else {
771
- yPoint = yNegativeStart + gapOffset;
772
- yNegativeStart = yPoint + barHeight;
791
+ barHeight = Math.abs(heightValueScale * point.data);
792
+ // FIXME: The current scaling logic may produce different min and gap heights for each bar stack.
793
+ const minHeight = Math.max(heightValueScale * absStackTotal / 100.0, barMinimumHeight);
794
+ if (barHeight < minHeight) {
795
+ barHeight = minHeight;
796
+ }
797
+ if (point.data >= Y_ORIGIN) {
798
+ yPositiveStart -= barHeight + gapOffset;
799
+ yPoint = yPositiveStart;
800
+ } else {
801
+ yPoint = yNegativeStart + gapOffset;
802
+ yNegativeStart = yPoint + barHeight;
803
+ }
804
+ barTotalValue += point.data;
805
+ heightOfLastBar = index === barsToDisplay.length - 1 ? barHeight : 0;
773
806
  }
774
- barTotalValue += point.data;
775
- heightOfLastBar = index === barsToDisplay.length - 1 ? barHeight : 0;
776
807
  if (barCornerRadius && barHeight > barCornerRadius && index === barsToDisplay.length - 1) {
777
808
  return /*#__PURE__*/ React.createElement(React.Fragment, {
778
809
  key: index + indexNumber + `${shouldFocusWholeStack}`
@@ -818,7 +849,11 @@ export const VerticalStackedBarChart = (props)=>{
818
849
  }));
819
850
  });
820
851
  const groupRef = {};
821
- const stackFocusProps = shouldFocusWholeStack && {
852
+ const someBarsActive = singleChartData.chartData.filter((dataPoint)=>_noLegendHighlighted() || _isLegendHighlighted(dataPoint.legend)).length > 0;
853
+ // FIXME: Making the entire stack focusable when stack callout is enabled adds unnecessary complexity
854
+ // and can reduce usability in certain scenarios. Instead, each individual element within the stack
855
+ // should be focusable on its own, with its own aria-label. This behavior is also seen in Highcharts.
856
+ const stackFocusProps = shouldFocusWholeStack && someBarsActive && {
822
857
  'aria-label': _getAriaLabel(singleChartData),
823
858
  onMouseOver: (event)=>_onStackHover(singleChartData, event),
824
859
  onMouseMove: (event)=>_onStackHover(singleChartData, event),
@@ -831,7 +866,7 @@ export const VerticalStackedBarChart = (props)=>{
831
866
  };
832
867
  let showLabel = false;
833
868
  let barLabel = 0;
834
- if (!props.hideLabels) {
869
+ if (!props.hideLabels && _yAxisType !== YAxisType.StringAxis) {
835
870
  if (_noLegendHighlighted()) {
836
871
  showLabel = true;
837
872
  barLabel = barTotalValue;
@@ -901,6 +936,83 @@ export const VerticalStackedBarChart = (props)=>{
901
936
  endValue: d3Max(values)
902
937
  };
903
938
  }
939
+ function _initYAxisParams() {
940
+ if (_points[0].chartData.length > 0) {
941
+ _yAxisType = getTypeOfAxis(_points[0].chartData[0].data, false);
942
+ } else {
943
+ Object.keys(_lineObject).forEach((lineLegend)=>{
944
+ if (!_lineObject[lineLegend][0].useSecondaryYScale) {
945
+ _yAxisType = getTypeOfAxis(_lineObject[lineLegend][0].y, false);
946
+ }
947
+ });
948
+ }
949
+ _yAxisLabels = _getOrderedYAxisLabels();
950
+ }
951
+ function _getYDomainMargins(containerHeight) {
952
+ /**
953
+ * Specifies the extra top margin to apply above the highest y-axis tick label.
954
+ * Useful when stacked bars extend beyond the combined height of all y-axis labels (or categories).
955
+ */ let yAxisTickMarginTop = 0;
956
+ /** Total height available to render the bars */ const totalHeight = containerHeight - _margins.bottom - _margins.top;
957
+ if (_yAxisType === YAxisType.StringAxis) {
958
+ /** Maximum height of the stacked bars, expressed in multiples of the height of a y-axis label (or category) */ let maxBarHeightInLabels = 0;
959
+ _points.forEach((xPoint)=>{
960
+ /** Height of the stacked bar, expressed in multiples of the height of a y-axis label (or category) */ let barHeightInLabels = 0;
961
+ xPoint.chartData.forEach((bar)=>{
962
+ barHeightInLabels += _yAxisLabels.indexOf(`${bar.data}`) + 1;
963
+ });
964
+ maxBarHeightInLabels = Math.max(maxBarHeightInLabels, barHeightInLabels);
965
+ });
966
+ /** Height of a y-axis label (or category) */ const yAxisLabelHeight = maxBarHeightInLabels === 0 ? 0 : totalHeight / maxBarHeightInLabels;
967
+ yAxisTickMarginTop += yAxisLabelHeight * (maxBarHeightInLabels - _yAxisLabels.length);
968
+ }
969
+ return {
970
+ ..._margins,
971
+ top: _margins.top + yAxisTickMarginTop
972
+ };
973
+ }
974
+ function _getOrderedXAxisLabels() {
975
+ if (_xAxisType !== XAxisTypes.StringAxis) {
976
+ return [];
977
+ }
978
+ return sortAxisCategories(_mapCategoryToValues(), props.xAxisCategoryOrder);
979
+ }
980
+ function _getOrderedYAxisLabels() {
981
+ if (_yAxisType !== YAxisType.StringAxis) {
982
+ return [];
983
+ }
984
+ return sortAxisCategories(_mapCategoryToValues(true), props.yAxisCategoryOrder);
985
+ }
986
+ function _mapCategoryToValues(isYAxis = false) {
987
+ const categoryToValues = {};
988
+ _points.forEach((point)=>{
989
+ var _point_lineData;
990
+ point.chartData.forEach((bar)=>{
991
+ const category = isYAxis ? bar.data : point.xAxisPoint;
992
+ const value = isYAxis ? point.xAxisPoint : bar.data;
993
+ if (!categoryToValues[category]) {
994
+ categoryToValues[category] = [];
995
+ }
996
+ if (typeof value === 'number') {
997
+ categoryToValues[category].push(value);
998
+ }
999
+ });
1000
+ (_point_lineData = point.lineData) === null || _point_lineData === void 0 ? void 0 : _point_lineData.forEach((linePoint)=>{
1001
+ if (isYAxis && linePoint.useSecondaryYScale) {
1002
+ return;
1003
+ }
1004
+ const category = isYAxis ? linePoint.y : point.xAxisPoint;
1005
+ const value = isYAxis ? point.xAxisPoint : linePoint.y;
1006
+ if (!categoryToValues[category]) {
1007
+ categoryToValues[category] = [];
1008
+ }
1009
+ if (typeof value === 'number') {
1010
+ categoryToValues[category].push(value);
1011
+ }
1012
+ });
1013
+ });
1014
+ return categoryToValues;
1015
+ }
904
1016
  if (!_isChartEmpty()) {
905
1017
  _adjustProps();
906
1018
  const _isHavingLines = props.data.some((item)=>item.lineData && item.lineData.length > 0);
@@ -956,6 +1068,12 @@ export const VerticalStackedBarChart = (props)=>{
956
1068
  },
957
1069
  componentRef: cartesianChartRef,
958
1070
  showRoundOffXTickValues: !isScalePaddingDefined(props.xAxisInnerPadding, props.xAxisPadding),
1071
+ yAxisType: _yAxisType,
1072
+ stringDatasetForYAxisDomain: [
1073
+ '',
1074
+ ..._yAxisLabels
1075
+ ],
1076
+ getYDomainMargins: _getYDomainMargins,
959
1077
  /* eslint-disable react/jsx-no-bind */ children: (props)=>{
960
1078
  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)));
961
1079
  }
@@ -969,5 +1087,5 @@ export const VerticalStackedBarChart = (props)=>{
969
1087
  },
970
1088
  "aria-label": 'Graph has no data to display'
971
1089
  });
972
- };
1090
+ });
973
1091
  VerticalStackedBarChart.displayName = 'VerticalStackedBarChart';