@fluentui/react-charts 9.2.2 → 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 (153) hide show
  1. package/CHANGELOG.md +35 -2
  2. package/dist/index.d.ts +89 -10
  3. package/lib/components/AreaChart/AreaChart.js +4 -1
  4. package/lib/components/AreaChart/AreaChart.js.map +1 -1
  5. package/lib/components/AreaChart/useAreaChartStyles.styles.js +2 -1
  6. package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
  7. package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js +2 -1
  8. package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
  9. package/lib/components/ChartTable/ChartTable.js +3 -2
  10. package/lib/components/ChartTable/ChartTable.js.map +1 -1
  11. package/lib/components/CommonComponents/CartesianChart.js +60 -19
  12. package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
  13. package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
  14. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +13 -0
  15. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  16. package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +12 -0
  17. package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
  18. package/lib/components/DeclarativeChart/DeclarativeChart.js +175 -107
  19. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  20. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +6 -1
  21. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
  22. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +791 -199
  23. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  24. package/lib/components/DonutChart/DonutChart.js +2 -2
  25. package/lib/components/DonutChart/DonutChart.js.map +1 -1
  26. package/lib/components/GanttChart/useGanttChartStyles.styles.js +2 -1
  27. package/lib/components/GanttChart/useGanttChartStyles.styles.js.map +1 -1
  28. package/lib/components/GanttChart/useGanttChartStyles.styles.raw.js +2 -1
  29. package/lib/components/GanttChart/useGanttChartStyles.styles.raw.js.map +1 -1
  30. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +29 -8
  31. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  32. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +2 -1
  33. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  34. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +2 -1
  35. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
  36. package/lib/components/HeatMapChart/HeatMapChart.js +175 -114
  37. package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
  38. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js +2 -1
  39. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
  40. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +2 -1
  41. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
  42. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +26 -6
  43. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  44. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +2 -1
  45. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
  46. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +2 -1
  47. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
  48. package/lib/components/LineChart/LineChart.js +251 -78
  49. package/lib/components/LineChart/LineChart.js.map +1 -1
  50. package/lib/components/LineChart/LineChart.types.js.map +1 -1
  51. package/lib/components/LineChart/useLineChartStyles.styles.js +10 -3
  52. package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  53. package/lib/components/LineChart/useLineChartStyles.styles.raw.js +14 -2
  54. package/lib/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
  55. package/lib/components/ScatterChart/ScatterChart.js +56 -37
  56. package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
  57. package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -1
  58. package/lib/components/ScatterChart/useScatterChartStyles.styles.js +21 -4
  59. package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  60. package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js +16 -3
  61. package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
  62. package/lib/components/VerticalBarChart/VerticalBarChart.js +27 -4
  63. package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  64. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +2 -1
  65. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  66. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +2 -1
  67. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
  68. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +158 -46
  69. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  70. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
  71. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +2 -1
  72. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
  73. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +2 -1
  74. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
  75. package/lib/types/DataPoint.js.map +1 -1
  76. package/lib/utilities/utilities.js +15 -5
  77. package/lib/utilities/utilities.js.map +1 -1
  78. package/lib-commonjs/components/AreaChart/AreaChart.js +4 -1
  79. package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
  80. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js +2 -1
  81. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
  82. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js +2 -1
  83. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
  84. package/lib-commonjs/components/ChartTable/ChartTable.js +3 -2
  85. package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -1
  86. package/lib-commonjs/components/CommonComponents/CartesianChart.js +60 -18
  87. package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
  88. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
  89. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +13 -0
  90. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  91. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +12 -0
  92. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
  93. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +171 -105
  94. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  95. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +9 -1
  96. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
  97. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +810 -197
  98. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  99. package/lib-commonjs/components/DonutChart/DonutChart.js +1 -1
  100. package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
  101. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js +2 -1
  102. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js.map +1 -1
  103. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.raw.js +2 -1
  104. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.raw.js.map +1 -1
  105. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +28 -7
  106. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  107. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +2 -1
  108. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  109. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +2 -1
  110. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
  111. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +174 -113
  112. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
  113. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js +2 -1
  114. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
  115. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +2 -1
  116. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
  117. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +25 -5
  118. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  119. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +2 -1
  120. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
  121. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +2 -1
  122. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
  123. package/lib-commonjs/components/LineChart/LineChart.js +250 -78
  124. package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
  125. package/lib-commonjs/components/LineChart/LineChart.types.js.map +1 -1
  126. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js +12 -3
  127. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  128. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js +14 -2
  129. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
  130. package/lib-commonjs/components/ScatterChart/ScatterChart.js +56 -37
  131. package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
  132. package/lib-commonjs/components/ScatterChart/ScatterChart.types.js.map +1 -1
  133. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js +30 -3
  134. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  135. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js +15 -2
  136. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
  137. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +26 -3
  138. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  139. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +2 -1
  140. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  141. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +2 -1
  142. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
  143. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +157 -45
  144. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  145. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
  146. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +2 -1
  147. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
  148. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +2 -1
  149. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
  150. package/lib-commonjs/types/DataPoint.js.map +1 -1
  151. package/lib-commonjs/utilities/utilities.js +15 -4
  152. package/lib-commonjs/utilities/utilities.js.map +1 -1
  153. package/package.json +10 -10
@@ -19,10 +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
- const VerticalStackedBarChart = (props)=>{
26
+ const VerticalStackedBarChart = /*#__PURE__*/ _react.forwardRef((props = {
27
+ xAxisCategoryOrder: 'default',
28
+ yAxisCategoryOrder: 'default',
29
+ data: []
30
+ }, forwardedRef)=>{
26
31
  var _props_legendProps;
27
32
  const _isRtl = (0, _index1.useRtl)();
28
33
  const _createLegendsForLine = (data)=>_getLineLegends(data);
@@ -46,6 +51,8 @@ const VerticalStackedBarChart = (props)=>{
46
51
  const cartesianChartRef = _react.useRef(null);
47
52
  const Y_ORIGIN = 0;
48
53
  const _legendsRef = _react.useRef(null);
54
+ let _yAxisType;
55
+ let _yAxisLabels = [];
49
56
  const [selectedLegends, setSelectedLegends] = _react.useState(((_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.selectedLegends) || []);
50
57
  const [activeLegend, setActiveLegend] = _react.useState(undefined);
51
58
  const [dataForHoverCard, setDataForHoverCard] = _react.useState(0);
@@ -246,21 +253,26 @@ const VerticalStackedBarChart = (props)=>{
246
253
  _lineObject = _getFormattedLineData(props.data);
247
254
  _xAxisInnerPadding = (0, _index1.getScalePadding)(props.xAxisInnerPadding, props.xAxisPadding, _xAxisType === _index1.XAxisTypes.StringAxis ? 2 / 3 : 1 / 2);
248
255
  _xAxisOuterPadding = (0, _index1.getScalePadding)(props.xAxisOuterPadding, props.xAxisPadding, 0);
256
+ _initYAxisParams();
249
257
  }
250
258
  function _createDataSetLayer() {
251
- const tempArr = [];
252
259
  const dataset = _points.map((singlePointData)=>{
260
+ if (_yAxisType === _index1.YAxisType.StringAxis) {
261
+ return {
262
+ x: singlePointData.xAxisPoint,
263
+ y: 0
264
+ };
265
+ }
253
266
  let total = 0;
254
267
  singlePointData.chartData.forEach((point)=>{
255
268
  total = total + point.data;
256
269
  });
257
- tempArr.push(singlePointData.xAxisPoint);
258
270
  return {
259
271
  x: singlePointData.xAxisPoint,
260
272
  y: total
261
273
  };
262
274
  });
263
- _xAxisLabels = tempArr;
275
+ _xAxisLabels = _getOrderedXAxisLabels();
264
276
  return dataset;
265
277
  }
266
278
  function _onLegendHover(legendTitle) {
@@ -285,7 +297,7 @@ const VerticalStackedBarChart = (props)=>{
285
297
  }
286
298
  function _getGraphData(xScale, yScale, containerHeight, containerWidth, xElement) {
287
299
  const { xBarScale, yBarScale } = _getScales(containerHeight, containerWidth);
288
- return _bars = _createBar(xBarScale, yBarScale, containerHeight, xElement);
300
+ return _bars = _createBar(xBarScale, _yAxisType === _index1.YAxisType.StringAxis ? yScale : yBarScale, containerHeight, xElement);
289
301
  }
290
302
  function _getAxisData(yAxisData) {
291
303
  if (yAxisData && yAxisData.yAxisDomainValues.length) {
@@ -295,16 +307,16 @@ const VerticalStackedBarChart = (props)=>{
295
307
  }
296
308
  }
297
309
  /**
298
- * This function checks if the given legend is highlighted or not.
299
- * A legend can be highlighted in 2 ways:
300
- * 1. selection: if the user clicks on it
301
- * 2. hovering: if there is no selected legend and the user hovers over it
302
- */ 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) {
303
315
  return _getHighlightedLegend().includes(legendTitle);
304
316
  }
305
317
  /**
306
- * This function checks if none of the legends is selected or hovered.
307
- */ function _noLegendHighlighted() {
318
+ * This function checks if none of the legends is selected or hovered.
319
+ */ function _noLegendHighlighted() {
308
320
  return _getHighlightedLegend().length === 0;
309
321
  }
310
322
  function _getAriaLabel(singleChartData, point, isLinePoint) {
@@ -412,6 +424,7 @@ const VerticalStackedBarChart = (props)=>{
412
424
  const y1 = useSecondaryYScale ? yScaleSecondary(lineObject[item][i - 1].y) : yScalePrimary(lineObject[item][i - 1].y);
413
425
  const x2 = xScale(lineObject[item][i].xItem.xAxisPoint);
414
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;
415
428
  if (lineBorderWidth > 0) {
416
429
  borderForLines.push(/*#__PURE__*/ _react.createElement("line", {
417
430
  key: `${index}-${i}-BorderLine`,
@@ -424,7 +437,7 @@ const VerticalStackedBarChart = (props)=>{
424
437
  fill: "transparent",
425
438
  strokeLinecap: "round",
426
439
  stroke: _reacttheme.tokens.colorNeutralBackground1,
427
- transform: `translate(${xScaleBandwidthTranslate}, 0)`
440
+ transform: `translate(${xScaleBandwidthTranslate}, ${yScaleBandwidthTranslate})`
428
441
  }));
429
442
  }
430
443
  var _lineObject_item__lineOptions_strokeWidth, _lineObject_item__lineOptions_strokeLinecap;
@@ -439,7 +452,7 @@ const VerticalStackedBarChart = (props)=>{
439
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',
440
453
  strokeDasharray: (_lineObject_item__lineOptions2 = lineObject[item][0].lineOptions) === null || _lineObject_item__lineOptions2 === void 0 ? void 0 : _lineObject_item__lineOptions2.strokeDasharray,
441
454
  stroke: lineObject[item][i].color,
442
- transform: `translate(${xScaleBandwidthTranslate}, 0)`,
455
+ transform: `translate(${xScaleBandwidthTranslate}, ${yScaleBandwidthTranslate})`,
443
456
  onMouseOver: (event)=>_lineHover(lineObject[item][i - 1], event),
444
457
  onMouseLeave: _handleMouseOut
445
458
  }));
@@ -451,6 +464,7 @@ const VerticalStackedBarChart = (props)=>{
451
464
  refElement: null
452
465
  };
453
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;
454
468
  dots.push(/*#__PURE__*/ _react.createElement("circle", {
455
469
  key: `${index}-${subIndex}-dot`,
456
470
  cx: xScale(circlePoint.xItem.xAxisPoint),
@@ -464,7 +478,7 @@ const VerticalStackedBarChart = (props)=>{
464
478
  // Elements with visibility: hidden cannot receive focus, so use opacity: 0 instead to hide them.
465
479
  // For more information, see https://fuzzbomb.github.io/accessibility-demos/visually-hidden-focus-test.html
466
480
  opacity: _getCircleOpacityAndRadius(circlePoint.xItem.xAxisPoint, circlePoint.legend).opacity,
467
- transform: `translate(${xScaleBandwidthTranslate}, 0)`,
481
+ transform: `translate(${xScaleBandwidthTranslate}, ${yScaleBandwidthTranslate})`,
468
482
  ref: (e)=>circleRef.refElement = e,
469
483
  ...noBarsAndLinesActive ? {
470
484
  tabIndex: !props.hideTooltip ? 0 : undefined,
@@ -536,14 +550,15 @@ const VerticalStackedBarChart = (props)=>{
536
550
  if ((_calloutAnchorPoint === null || _calloutAnchorPoint === void 0 ? void 0 : _calloutAnchorPoint.chartDataPoint) !== point || (_calloutAnchorPoint === null || _calloutAnchorPoint === void 0 ? void 0 : _calloutAnchorPoint.xAxisDataPoint) !== xAxisPoint) {
537
551
  _calloutAnchorPoint = {
538
552
  chartDataPoint: point,
539
- xAxisDataPoint: `${xAxisPoint}`
553
+ xAxisDataPoint: xAxisPoint instanceof Date ? (0, _chartutilities.formatDateToLocaleString)(xAxisPoint, props.culture, props.useUTC) : xAxisPoint.toString()
540
554
  };
555
+ const xCalloutValue = point.xAxisCalloutData || (xAxisPoint instanceof Date ? (0, _chartutilities.formatDateToLocaleString)(xAxisPoint, props.culture, props.useUTC) : xAxisPoint.toString());
541
556
  _updatePosition(clientX, clientY);
542
557
  setPopoverOpen(_noLegendHighlighted() || _isLegendHighlighted(point.legend));
543
558
  setCalloutLegend(point.legend);
544
559
  setDataForHoverCard(point.data);
545
560
  setColor(color);
546
- setXCalloutValue(point.xAxisCalloutData ? point.xAxisCalloutData : `${xAxisPoint}`);
561
+ setXCalloutValue(xCalloutValue);
547
562
  setYCalloutValue(point.yAxisCalloutData);
548
563
  setDataPointCalloutProps(point);
549
564
  setCallOutAccessibilityData(point.callOutAccessibilityData);
@@ -577,22 +592,29 @@ const VerticalStackedBarChart = (props)=>{
577
592
  }
578
593
  function _getBarGapAndScale(bars, yBarScale, defaultTotalHeight) {
579
594
  const { barGapMax = 0 } = props;
580
- // When displaying gaps between the bars, the height of each bar is
581
- // adjusted so that the total of all bars is not changed by the gaps
582
- const totalData = bars.reduce((iter, value)=>iter + Math.abs(value.data), 0);
583
- const totalHeight = defaultTotalHeight !== null && defaultTotalHeight !== void 0 ? defaultTotalHeight : Math.abs(yBarScale(totalData) - yBarScale(Y_ORIGIN));
595
+ let totalData = 0;
596
+ let totalHeight;
584
597
  let sumOfPercent = 0;
585
- bars.forEach((point)=>{
586
- let value = Math.abs(point.data) / totalData * 100;
587
- if (value < 1 && value !== 0) {
588
- value = 1;
589
- }
590
- sumOfPercent += value;
591
- });
592
- 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
+ }
593
615
  const gaps = barGapMax && bars.length - 1;
594
616
  const gapHeight = gaps && Math.max(barGapMin, Math.min(barGapMax, totalHeight * barGapMultiplier / gaps));
595
- const heightValueScale = (totalHeight - gapHeight * gaps) / (totalData * scalingRatio);
617
+ const heightValueScale = _yAxisType === _index1.YAxisType.StringAxis ? 0 : (totalHeight - gapHeight * gaps) / (totalData * scalingRatio);
596
618
  return {
597
619
  gapHeight,
598
620
  heightValueScale,
@@ -742,7 +764,7 @@ const VerticalStackedBarChart = (props)=>{
742
764
  const xPoint = xBarScale(_xAxisType === _index1.XAxisTypes.NumericAxis ? singleChartData.xAxisPoint : _xAxisType === _index1.XAxisTypes.DateAxis ? singleChartData.xAxisPoint : singleChartData.xAxisPoint);
743
765
  const xScaleBandwidthTranslate = _xAxisType !== _index1.XAxisTypes.StringAxis ? -_barWidth / 2 : (xBarScale.bandwidth() - _barWidth) / 2;
744
766
  let barTotalValue = 0;
745
- 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'));
746
768
  if (!barsToDisplay.length) {
747
769
  return undefined;
748
770
  }
@@ -750,7 +772,7 @@ const VerticalStackedBarChart = (props)=>{
750
772
  if (heightValueScale < 0) {
751
773
  return undefined;
752
774
  }
753
- const yBaseline = containerHeight - _margins.bottom - yBarScale(Y_ORIGIN);
775
+ const yBaseline = containerHeight - _margins.bottom - (_yAxisType === _index1.YAxisType.StringAxis ? 0 : yBarScale(Y_ORIGIN));
754
776
  let yPositiveStart = yBaseline;
755
777
  let yNegativeStart = yBaseline;
756
778
  let yPoint = 0;
@@ -770,22 +792,29 @@ const VerticalStackedBarChart = (props)=>{
770
792
  role: 'img',
771
793
  tabIndex: !props.hideTooltip && shouldHighlight ? 0 : undefined
772
794
  };
773
- let barHeight = Math.abs(heightValueScale * point.data);
774
- // FIXME: The current scaling logic may produce different min and gap heights for each bar stack.
775
- const minHeight = Math.max(heightValueScale * absStackTotal / 100.0, barMinimumHeight);
776
- if (barHeight < minHeight) {
777
- barHeight = minHeight;
778
- }
795
+ let barHeight;
779
796
  const gapOffset = index ? gapHeight : 0;
780
- 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);
781
799
  yPositiveStart -= barHeight + gapOffset;
782
800
  yPoint = yPositiveStart;
783
801
  } else {
784
- yPoint = yNegativeStart + gapOffset;
785
- 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;
786
817
  }
787
- barTotalValue += point.data;
788
- heightOfLastBar = index === barsToDisplay.length - 1 ? barHeight : 0;
789
818
  if (barCornerRadius && barHeight > barCornerRadius && index === barsToDisplay.length - 1) {
790
819
  return /*#__PURE__*/ _react.createElement(_react.Fragment, {
791
820
  key: index + indexNumber + `${shouldFocusWholeStack}`
@@ -848,7 +877,7 @@ const VerticalStackedBarChart = (props)=>{
848
877
  };
849
878
  let showLabel = false;
850
879
  let barLabel = 0;
851
- if (!props.hideLabels) {
880
+ if (!props.hideLabels && _yAxisType !== _index1.YAxisType.StringAxis) {
852
881
  if (_noLegendHighlighted()) {
853
882
  showLabel = true;
854
883
  barLabel = barTotalValue;
@@ -918,6 +947,83 @@ const VerticalStackedBarChart = (props)=>{
918
947
  endValue: (0, _d3array.max)(values)
919
948
  };
920
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
+ }
921
1027
  if (!_isChartEmpty()) {
922
1028
  _adjustProps();
923
1029
  const _isHavingLines = props.data.some((item)=>item.lineData && item.lineData.length > 0);
@@ -973,6 +1079,12 @@ const VerticalStackedBarChart = (props)=>{
973
1079
  },
974
1080
  componentRef: cartesianChartRef,
975
1081
  showRoundOffXTickValues: !(0, _index1.isScalePaddingDefined)(props.xAxisInnerPadding, props.xAxisPadding),
1082
+ yAxisType: _yAxisType,
1083
+ stringDatasetForYAxisDomain: [
1084
+ '',
1085
+ ..._yAxisLabels
1086
+ ],
1087
+ getYDomainMargins: _getYDomainMargins,
976
1088
  /* eslint-disable react/jsx-no-bind */ children: (props)=>{
977
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)));
978
1090
  }
@@ -986,5 +1098,5 @@ const VerticalStackedBarChart = (props)=>{
986
1098
  },
987
1099
  "aria-label": 'Graph has no data to display'
988
1100
  });
989
- };
1101
+ });
990
1102
  VerticalStackedBarChart.displayName = 'VerticalStackedBarChart';