@fluentui/react-charts 9.0.2 → 9.0.4

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 (229) hide show
  1. package/CHANGELOG.md +64 -7
  2. package/dist/index.d.ts +829 -94
  3. package/lib/AreaChart.js +1 -0
  4. package/lib/AreaChart.js.map +1 -0
  5. package/lib/HeatMapChart.js +1 -0
  6. package/lib/HeatMapChart.js.map +1 -0
  7. package/lib/HorizontalBarChartWithAxis.js +1 -0
  8. package/lib/HorizontalBarChartWithAxis.js.map +1 -0
  9. package/lib/SankeyChart.js +1 -0
  10. package/lib/SankeyChart.js.map +1 -0
  11. package/lib/VerticalStackedBarChart.js +1 -0
  12. package/lib/VerticalStackedBarChart.js.map +1 -0
  13. package/lib/components/AreaChart/AreaChart.js +775 -0
  14. package/lib/components/AreaChart/AreaChart.js.map +1 -0
  15. package/lib/components/AreaChart/AreaChart.types.js +4 -0
  16. package/lib/components/AreaChart/AreaChart.types.js.map +1 -0
  17. package/lib/components/AreaChart/index.js +3 -0
  18. package/lib/components/AreaChart/index.js.map +1 -0
  19. package/lib/components/AreaChart/useAreaChartStyles.styles.js +55 -0
  20. package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -0
  21. package/lib/components/CommonComponents/CartesianChart.js +30 -14
  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.js +2 -2
  25. package/lib/components/CommonComponents/ChartPopover.js.map +1 -1
  26. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +7 -123
  27. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  28. package/lib/components/CommonComponents/useChartPopoverStyles.styles.js +11 -22
  29. package/lib/components/CommonComponents/useChartPopoverStyles.styles.js.map +1 -1
  30. package/lib/components/DeclarativeChart/DeclarativeChart.js +112 -65
  31. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  32. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +570 -159
  33. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  34. package/lib/components/DonutChart/Arc/Arc.js +1 -1
  35. package/lib/components/DonutChart/Arc/Arc.js.map +1 -1
  36. package/lib/components/DonutChart/DonutChart.js +1 -1
  37. package/lib/components/DonutChart/DonutChart.js.map +1 -1
  38. package/lib/components/DonutChart/Pie/usePieStyles.styles.js +2 -6
  39. package/lib/components/DonutChart/Pie/usePieStyles.styles.js.map +1 -1
  40. package/lib/components/GaugeChart/GaugeChart.js +4 -1
  41. package/lib/components/GaugeChart/GaugeChart.js.map +1 -1
  42. package/lib/components/GaugeChart/GaugeChart.types.js.map +1 -1
  43. package/lib/components/GaugeChart/useGaugeChartStyles.styles.js +13 -9
  44. package/lib/components/GaugeChart/useGaugeChartStyles.styles.js.map +1 -1
  45. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +9 -0
  46. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  47. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +0 -9
  48. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  49. package/lib/components/HeatMapChart/HeatMapChart.js +588 -0
  50. package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -0
  51. package/lib/components/HeatMapChart/HeatMapChart.types.js +4 -0
  52. package/lib/components/HeatMapChart/HeatMapChart.types.js.map +1 -0
  53. package/lib/components/HeatMapChart/index.js +3 -0
  54. package/lib/components/HeatMapChart/index.js.map +1 -0
  55. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js +37 -0
  56. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -0
  57. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +2 -9
  58. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
  59. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +571 -0
  60. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -0
  61. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js +4 -0
  62. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js.map +1 -0
  63. package/lib/components/HorizontalBarChartWithAxis/index.js +3 -0
  64. package/lib/components/HorizontalBarChartWithAxis/index.js.map +1 -0
  65. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +67 -0
  66. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -0
  67. package/lib/components/Legends/Legends.js +38 -37
  68. package/lib/components/Legends/Legends.js.map +1 -1
  69. package/lib/components/Legends/useLegendsStyles.styles.js +2 -3
  70. package/lib/components/Legends/useLegendsStyles.styles.js.map +1 -1
  71. package/lib/components/LineChart/LineChart.js +43 -35
  72. package/lib/components/LineChart/LineChart.js.map +1 -1
  73. package/lib/components/LineChart/useLineChartStyles.styles.js +1 -10
  74. package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  75. package/lib/components/SankeyChart/SankeyChart.js +1023 -0
  76. package/lib/components/SankeyChart/SankeyChart.js.map +1 -0
  77. package/lib/components/SankeyChart/SankeyChart.types.js +3 -0
  78. package/lib/components/SankeyChart/SankeyChart.types.js.map +1 -0
  79. package/lib/components/SankeyChart/index.js +3 -0
  80. package/lib/components/SankeyChart/index.js.map +1 -0
  81. package/lib/components/SankeyChart/useSankeyChartStyles.styles.js +109 -0
  82. package/lib/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -0
  83. package/lib/components/ScatterChart/ScatterChart.js +46 -59
  84. package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
  85. package/lib/components/ScatterChart/useScatterChartStyles.styles.js +1 -10
  86. package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  87. package/lib/components/VerticalBarChart/VerticalBarChart.js +165 -88
  88. package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  89. package/lib/components/VerticalBarChart/VerticalBarChart.types.js.map +1 -1
  90. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +3 -11
  91. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  92. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +904 -0
  93. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -0
  94. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js +1 -0
  95. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -0
  96. package/lib/components/VerticalStackedBarChart/index.js +3 -0
  97. package/lib/components/VerticalStackedBarChart/index.js.map +1 -0
  98. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +65 -0
  99. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -0
  100. package/lib/index.js +5 -0
  101. package/lib/index.js.map +1 -1
  102. package/lib/types/DataPoint.js +1 -3
  103. package/lib/types/DataPoint.js.map +1 -1
  104. package/lib/utilities/SVGTooltipText.js +49 -4
  105. package/lib/utilities/SVGTooltipText.js.map +1 -1
  106. package/lib/utilities/colors.js +20 -0
  107. package/lib/utilities/colors.js.map +1 -1
  108. package/lib/utilities/string.js +32 -0
  109. package/lib/utilities/string.js.map +1 -0
  110. package/lib/utilities/test-data.js +53 -0
  111. package/lib/utilities/test-data.js.map +1 -1
  112. package/lib/utilities/utilities.js +90 -18
  113. package/lib/utilities/utilities.js.map +1 -1
  114. package/lib-commonjs/AreaChart.js +6 -0
  115. package/lib-commonjs/AreaChart.js.map +1 -0
  116. package/lib-commonjs/HeatMapChart.js +6 -0
  117. package/lib-commonjs/HeatMapChart.js.map +1 -0
  118. package/lib-commonjs/HorizontalBarChartWithAxis.js +6 -0
  119. package/lib-commonjs/HorizontalBarChartWithAxis.js.map +1 -0
  120. package/lib-commonjs/SankeyChart.js +6 -0
  121. package/lib-commonjs/SankeyChart.js.map +1 -0
  122. package/lib-commonjs/VerticalStackedBarChart.js +6 -0
  123. package/lib-commonjs/VerticalStackedBarChart.js.map +1 -0
  124. package/lib-commonjs/components/AreaChart/AreaChart.js +781 -0
  125. package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -0
  126. package/lib-commonjs/components/AreaChart/AreaChart.types.js +7 -0
  127. package/lib-commonjs/components/AreaChart/AreaChart.types.js.map +1 -0
  128. package/lib-commonjs/components/AreaChart/index.js +8 -0
  129. package/lib-commonjs/components/AreaChart/index.js.map +1 -0
  130. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js +95 -0
  131. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -0
  132. package/lib-commonjs/components/CommonComponents/CartesianChart.js +29 -14
  133. package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
  134. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
  135. package/lib-commonjs/components/CommonComponents/ChartPopover.js +2 -2
  136. package/lib-commonjs/components/CommonComponents/ChartPopover.js.map +1 -1
  137. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +8 -198
  138. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  139. package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js +12 -37
  140. package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js.map +1 -1
  141. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +120 -73
  142. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  143. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +592 -178
  144. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  145. package/lib-commonjs/components/DonutChart/Arc/Arc.js +1 -1
  146. package/lib-commonjs/components/DonutChart/Arc/Arc.js.map +1 -1
  147. package/lib-commonjs/components/DonutChart/DonutChart.js +1 -1
  148. package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
  149. package/lib-commonjs/components/DonutChart/Pie/usePieStyles.styles.js +3 -10
  150. package/lib-commonjs/components/DonutChart/Pie/usePieStyles.styles.js.map +1 -1
  151. package/lib-commonjs/components/GaugeChart/GaugeChart.js +4 -1
  152. package/lib-commonjs/components/GaugeChart/GaugeChart.js.map +1 -1
  153. package/lib-commonjs/components/GaugeChart/GaugeChart.types.js.map +1 -1
  154. package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.js +14 -8
  155. package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.js.map +1 -1
  156. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +9 -0
  157. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  158. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +0 -9
  159. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  160. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +599 -0
  161. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -0
  162. package/lib-commonjs/components/HeatMapChart/HeatMapChart.types.js +7 -0
  163. package/lib-commonjs/components/HeatMapChart/HeatMapChart.types.js.map +1 -0
  164. package/lib-commonjs/components/HeatMapChart/index.js +8 -0
  165. package/lib-commonjs/components/HeatMapChart/index.js.map +1 -0
  166. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js +59 -0
  167. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -0
  168. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +2 -16
  169. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
  170. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +580 -0
  171. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -0
  172. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js +7 -0
  173. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js.map +1 -0
  174. package/lib-commonjs/components/HorizontalBarChartWithAxis/index.js +8 -0
  175. package/lib-commonjs/components/HorizontalBarChartWithAxis/index.js.map +1 -0
  176. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +107 -0
  177. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -0
  178. package/lib-commonjs/components/Legends/Legends.js +37 -37
  179. package/lib-commonjs/components/Legends/Legends.js.map +1 -1
  180. package/lib-commonjs/components/Legends/useLegendsStyles.styles.js +2 -2
  181. package/lib-commonjs/components/Legends/useLegendsStyles.styles.js.map +1 -1
  182. package/lib-commonjs/components/LineChart/LineChart.js +41 -33
  183. package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
  184. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js +1 -10
  185. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  186. package/lib-commonjs/components/SankeyChart/SankeyChart.js +1039 -0
  187. package/lib-commonjs/components/SankeyChart/SankeyChart.js.map +1 -0
  188. package/lib-commonjs/components/SankeyChart/SankeyChart.types.js +6 -0
  189. package/lib-commonjs/components/SankeyChart/SankeyChart.types.js.map +1 -0
  190. package/lib-commonjs/components/SankeyChart/index.js +8 -0
  191. package/lib-commonjs/components/SankeyChart/index.js.map +1 -0
  192. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js +179 -0
  193. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -0
  194. package/lib-commonjs/components/ScatterChart/ScatterChart.js +45 -58
  195. package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
  196. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js +1 -10
  197. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  198. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +164 -87
  199. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  200. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.types.js.map +1 -1
  201. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +4 -11
  202. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  203. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +915 -0
  204. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -0
  205. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js +6 -0
  206. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -0
  207. package/lib-commonjs/components/VerticalStackedBarChart/index.js +8 -0
  208. package/lib-commonjs/components/VerticalStackedBarChart/index.js.map +1 -0
  209. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +113 -0
  210. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -0
  211. package/lib-commonjs/index.js +5 -0
  212. package/lib-commonjs/index.js.map +1 -1
  213. package/lib-commonjs/types/DataPoint.js +1 -3
  214. package/lib-commonjs/types/DataPoint.js.map +1 -1
  215. package/lib-commonjs/utilities/SVGTooltipText.js +49 -4
  216. package/lib-commonjs/utilities/SVGTooltipText.js.map +1 -1
  217. package/lib-commonjs/utilities/colors.js +23 -0
  218. package/lib-commonjs/utilities/colors.js.map +1 -1
  219. package/lib-commonjs/utilities/string.js +29 -0
  220. package/lib-commonjs/utilities/string.js.map +1 -0
  221. package/lib-commonjs/utilities/test-data.js +59 -0
  222. package/lib-commonjs/utilities/test-data.js.map +1 -1
  223. package/lib-commonjs/utilities/utilities.js +94 -17
  224. package/lib-commonjs/utilities/utilities.js.map +1 -1
  225. package/package.json +11 -8
  226. package/lib/components/DeclarativeChart/PlotlySchema.js +0 -7
  227. package/lib/components/DeclarativeChart/PlotlySchema.js.map +0 -1
  228. package/lib-commonjs/components/DeclarativeChart/PlotlySchema.js +0 -10
  229. package/lib-commonjs/components/DeclarativeChart/PlotlySchema.js.map +0 -1
@@ -26,6 +26,7 @@ var CircleVisbility;
26
26
  })(CircleVisbility || (CircleVisbility = {}));
27
27
  const MIN_DOMAIN_MARGIN = 8;
28
28
  const VerticalBarChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
29
+ var _props_legendProps;
29
30
  let _points = [];
30
31
  let _barWidth = 0;
31
32
  let _colors;
@@ -35,6 +36,7 @@ const VerticalBarChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>
35
36
  let _bars;
36
37
  let _xAxisLabels;
37
38
  let _yMax;
39
+ let _yMin;
38
40
  let _isHavingLine = _checkForLine();
39
41
  const _tooltipId = (0, _reactutilities.useId)('VCTooltipID_');
40
42
  const _xAxisType = props.data && props.data.length > 0 ? (0, _index1.getTypeOfAxis)(props.data[0].x, true) : _index1.XAxisTypes.StringAxis;
@@ -49,12 +51,11 @@ const VerticalBarChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>
49
51
  const cartesianChartRef = _react.useRef(null);
50
52
  const [color, setColor] = _react.useState('');
51
53
  const [dataForHoverCard, setDataForHoverCard] = _react.useState(0);
52
- const [selectedLegend, setSelectedLegend] = _react.useState('');
53
- const [activeLegend, setActiveLegend] = _react.useState('');
54
+ const [activeLegend, setActiveLegend] = _react.useState(undefined);
54
55
  const [xCalloutValue, setXCalloutValue] = _react.useState('');
55
56
  const [yCalloutValue, setYCalloutValue] = _react.useState('');
56
57
  const [activeXdataPoint, setActiveXDatapoint] = _react.useState(null);
57
- const [YValueHover, setYValueHover] = _react.useState();
58
+ const [hoveredYValues, setYValueHover] = _react.useState();
58
59
  const [hoverXValue, setHoverXValue] = _react.useState('');
59
60
  const [calloutLegend, setCalloutLegend] = _react.useState('');
60
61
  const [callOutAccessibilityData, setCalloutAccessibilityData] = _react.useState();
@@ -64,6 +65,8 @@ const VerticalBarChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>
64
65
  y: 0
65
66
  });
66
67
  const [isPopoverOpen, setPopoverOpen] = _react.useState(false);
68
+ const [selectedLegends, setSelectedLegends] = _react.useState(((_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.selectedLegends) || []);
69
+ const prevPropsRef = _react.useRef(null);
67
70
  _react.useImperativeHandle(props.componentRef, ()=>{
68
71
  var _cartesianChartRef_current;
69
72
  var _cartesianChartRef_current_chartContainer;
@@ -71,6 +74,24 @@ const VerticalBarChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>
71
74
  chartContainer: (_cartesianChartRef_current_chartContainer = (_cartesianChartRef_current = cartesianChartRef.current) === null || _cartesianChartRef_current === void 0 ? void 0 : _cartesianChartRef_current.chartContainer) !== null && _cartesianChartRef_current_chartContainer !== void 0 ? _cartesianChartRef_current_chartContainer : null
72
75
  };
73
76
  }, []);
77
+ _react.useEffect(()=>{
78
+ if (prevPropsRef.current) {
79
+ var _prevProps_legendProps, _props_legendProps;
80
+ const prevProps = prevPropsRef.current;
81
+ if (!(0, _index1.areArraysEqual)((_prevProps_legendProps = prevProps.legendProps) === null || _prevProps_legendProps === void 0 ? void 0 : _prevProps_legendProps.selectedLegends, (_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.selectedLegends)) {
82
+ var _props_legendProps1;
83
+ setSelectedLegends(((_props_legendProps1 = props.legendProps) === null || _props_legendProps1 === void 0 ? void 0 : _props_legendProps1.selectedLegends) || []);
84
+ }
85
+ if (prevProps.height !== props.height || prevProps.width !== props.width) {
86
+ _adjustProps();
87
+ }
88
+ }
89
+ prevPropsRef.current = props;
90
+ }, [
91
+ props,
92
+ prevPropsRef,
93
+ _adjustProps
94
+ ]);
74
95
  function _createLine(xScale, yScale, containerHeight = 0, containerWidth = 0, yScaleSecondary) {
75
96
  var _props_lineOptions;
76
97
  const isStringAxis = _xAxisType === _index1.XAxisTypes.StringAxis;
@@ -129,7 +150,7 @@ const VerticalBarChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>
129
150
  id: `${_vbcPointId}-${index}`,
130
151
  cx: isStringAxis ? xScale(item.x) + 0.5 * xScale.bandwidth() : xScale(item.x),
131
152
  cy: item.useSecondaryYScale && yScaleSecondary ? yScaleSecondary(item.y) : yScale(item.y),
132
- onMouseOver: _legendHighlighted(lineLegendText) ? _lineHover.bind(item.point) : (event)=>_onBarHover(item.point, colorScale(item.y), event),
153
+ onMouseOver: (event)=>_legendHighlighted(lineLegendText) ? _lineHover(item.point, event) : _onBarHover(item.point, colorScale(item.y), event),
133
154
  onMouseOut: _onBarLeave,
134
155
  r: _getCircleVisibilityAndRadius(item.x, lineLegendText).radius,
135
156
  stroke: lineLegendColor,
@@ -149,13 +170,13 @@ const VerticalBarChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>
149
170
  return /*#__PURE__*/ _react.createElement(_react.Fragment, null, line, dots);
150
171
  }
151
172
  function _getCircleVisibilityAndRadius(xAxisPoint, legend) {
152
- if (selectedLegend !== '') {
153
- if (xAxisPoint === activeXdataPoint && selectedLegend === legend) {
173
+ if (!_noLegendHighlighted()) {
174
+ if (xAxisPoint === activeXdataPoint && _legendHighlighted(legend)) {
154
175
  return {
155
176
  visibility: "visibility",
156
177
  radius: 8
157
178
  };
158
- } else if (selectedLegend === legend) {
179
+ } else if (_legendHighlighted(legend)) {
159
180
  // Don't hide the circle to keep it focusable. For more information,
160
181
  // see https://fuzzbomb.github.io/accessibility-demos/visually-hidden-focus-test.html
161
182
  return {
@@ -274,10 +295,10 @@ const VerticalBarChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>
274
295
  const { useSingleColor = false } = props;
275
296
  const { data, lineLegendText, lineLegendColor = _reacttheme.tokens.colorPaletteYellowBackground1 } = props;
276
297
  const selectedPoint = data.filter((xDataPoint)=>xDataPoint.x === point.x);
277
- // there might be no y value of the line for the hovered bar. so we need to check this condition
278
- if (_isHavingLine && ((_selectedPoint__lineData = selectedPoint[0].lineData) === null || _selectedPoint__lineData === void 0 ? void 0 : _selectedPoint__lineData.y) !== undefined) {
298
+ // Check if the line legend is highlighted or no legend is highlighted
299
+ if (_isHavingLine && ((_selectedPoint__lineData = selectedPoint[0].lineData) === null || _selectedPoint__lineData === void 0 ? void 0 : _selectedPoint__lineData.y) !== undefined && (_legendHighlighted(lineLegendText) || _noLegendHighlighted())) {
279
300
  var _selectedPoint__lineData1, _selectedPoint__lineData2, _selectedPoint__lineData3;
280
- // callout data for the line
301
+ // Add callout data for the line
281
302
  YValueHover.push({
282
303
  legend: lineLegendText,
283
304
  color: lineLegendColor,
@@ -286,14 +307,17 @@ const VerticalBarChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>
286
307
  yAxisCalloutData: (_selectedPoint__lineData3 = selectedPoint[0].lineData) === null || _selectedPoint__lineData3 === void 0 ? void 0 : _selectedPoint__lineData3.yAxisCalloutData
287
308
  });
288
309
  }
289
- // callout data for the bar
290
- YValueHover.push({
291
- legend: selectedPoint[0].legend,
292
- y: selectedPoint[0].y,
293
- color: !useSingleColor ? selectedPoint[0].color ? selectedPoint[0].color : _createColors()(selectedPoint[0].y) : _createColors()(1),
294
- data: selectedPoint[0].yAxisCalloutData,
295
- yAxisCalloutData: selectedPoint[0].yAxisCalloutData
296
- });
310
+ // Check if the bar legend is highlighted or no legend is highlighted
311
+ if (selectedPoint[0].legend && (selectedLegends.includes(selectedPoint[0].legend) || _noLegendHighlighted())) {
312
+ // Add callout data for the bar
313
+ YValueHover.push({
314
+ legend: selectedPoint[0].legend,
315
+ y: selectedPoint[0].y,
316
+ color: !useSingleColor ? selectedPoint[0].color ? selectedPoint[0].color : _createColors()(selectedPoint[0].y) : _createColors()(1),
317
+ data: selectedPoint[0].yAxisCalloutData,
318
+ yAxisCalloutData: selectedPoint[0].yAxisCalloutData
319
+ });
320
+ }
297
321
  // eslint-disable-next-line @typescript-eslint/no-shadow
298
322
  const hoverXValue = point.x instanceof Date ? point.x.toLocaleString() : point.x.toString();
299
323
  return {
@@ -308,7 +332,7 @@ const VerticalBarChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>
308
332
  if (_calloutAnchorPoint !== point) {
309
333
  _calloutAnchorPoint = point;
310
334
  /** Show the callout if highlighted bar is hovered and Hide it if unhighlighted bar is hovered */ updatePosition(mouseEvent.clientX, mouseEvent.clientY);
311
- setPopoverOpen(selectedLegend === '' || selectedLegend === point.legend);
335
+ setPopoverOpen(_noLegendHighlighted() || _legendHighlighted(point.legend));
312
336
  setDataForHoverCard(point.y);
313
337
  setCalloutLegend(point.legend);
314
338
  setColor(point.color || color);
@@ -337,7 +361,7 @@ const VerticalBarChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>
337
361
  const { YValueHover, hoverXValue } = _getCalloutContentForLineAndBar(point);
338
362
  _refArray.forEach((obj, index)=>{
339
363
  if (obj.index === point.legend && refArrayIndexNumber === index) {
340
- /** Show the callout if highlighted bar is hovered and Hide it if unhighlighted bar is hovered */ setPopoverOpen(selectedLegend === '' || selectedLegend === point.legend);
364
+ /** Show the callout if highlighted bar is hovered and Hide it if unhighlighted bar is hovered */ setPopoverOpen(_noLegendHighlighted() || _legendHighlighted(point.legend));
341
365
  setDataForHoverCard(point.y);
342
366
  setCalloutLegend(point.legend);
343
367
  setColor(point.color || color);
@@ -364,7 +388,7 @@ const VerticalBarChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>
364
388
  }
365
389
  function _lineHoverFocus(point, _refSelected) {
366
390
  const { lineLegendText = '', lineLegendColor = _reacttheme.tokens.colorPaletteYellowBackground1 } = props;
367
- setPopoverOpen(false);
391
+ setPopoverOpen(_noLegendHighlighted() || _legendHighlighted(lineLegendText));
368
392
  setCalloutLegend(lineLegendText);
369
393
  setDataForHoverCard(point.lineData.y);
370
394
  setColor(lineLegendColor);
@@ -378,7 +402,7 @@ const VerticalBarChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>
378
402
  let xBarScale;
379
403
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
380
404
  const yBarScale = (0, _d3scale.scaleLinear)().domain([
381
- 0,
405
+ _yMin,
382
406
  _yMax
383
407
  ]).range([
384
408
  0,
@@ -425,31 +449,40 @@ const VerticalBarChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>
425
449
  };
426
450
  }
427
451
  const classes = (0, _useVerticalBarChartStylesstyles.useVerticalBarChartStyles)(props);
452
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
453
+ function _calculateMinBarHeight(yMin, yMax, yReferencePoint, yBarScale) {
454
+ const maxHeightFromBaseline = yMax < 0 ? Math.abs(yMin - yReferencePoint) : Math.max(Math.abs(yMax - yReferencePoint), Math.abs(yMin - yReferencePoint));
455
+ return Math.ceil(yBarScale(maxHeightFromBaseline) / 100.0);
456
+ }
428
457
  function _createNumericBars(containerHeight, containerWidth, xElement) {
429
458
  const { useSingleColor = false } = props;
430
459
  const { xBarScale, yBarScale } = _getScales(containerHeight, containerWidth);
431
460
  const colorScale = _createColors();
461
+ const yReferencePoint = _yMax < 0 ? _yMax : 0;
432
462
  const bars = _points.map((point, index)=>{
433
463
  const shouldHighlight = _legendHighlighted(point.legend) || _noLegendHighlighted() ? true : false;
434
- const barHeight = Math.max(yBarScale(point.y), 0);
435
- let adjustedBarHeight = 0;
436
- if (barHeight <= 0) {
464
+ let barHeight = yBarScale(point.y) - yBarScale(yReferencePoint);
465
+ const isHeightNegative = barHeight < 0;
466
+ barHeight = Math.abs(barHeight);
467
+ // Calculate threshold for minimum visible bar height
468
+ const minBarHeight = _calculateMinBarHeight(_yMin, _yMax, yReferencePoint, yBarScale);
469
+ let adjustedBarHeight = barHeight;
470
+ if (barHeight === 0) {
437
471
  return /*#__PURE__*/ _react.createElement(_react.Fragment, {
438
472
  key: point.x
439
473
  }, " ");
440
- } else if (barHeight <= Math.ceil(yBarScale(_yMax) / 100.0)) {
441
- adjustedBarHeight = Math.ceil(yBarScale(_yMax) / 100.0);
442
- } else {
443
- adjustedBarHeight = barHeight;
474
+ } else if (barHeight <= minBarHeight) {
475
+ adjustedBarHeight = minBarHeight;
444
476
  }
445
477
  const xPoint = xBarScale(point.x) - _barWidth / 2;
446
- const yPoint = containerHeight - margins.bottom - adjustedBarHeight;
478
+ const yPoint = containerHeight - margins.bottom - (isHeightNegative ? -1 * adjustedBarHeight : adjustedBarHeight) - yBarScale(yReferencePoint);
479
+ const baselineHeight = containerHeight - margins.bottom - yBarScale(yReferencePoint);
447
480
  return /*#__PURE__*/ _react.createElement("g", {
448
- key: point.x
481
+ key: `${point.x}_${index}`
449
482
  }, /*#__PURE__*/ _react.createElement("rect", {
450
483
  id: `${_vbcBarId}-${index}`,
451
484
  x: xPoint,
452
- y: yPoint,
485
+ y: !isHeightNegative ? yPoint : baselineHeight,
453
486
  width: _barWidth,
454
487
  "data-is-focusable": !props.hideTooltip && shouldHighlight,
455
488
  height: adjustedBarHeight,
@@ -465,8 +498,9 @@ const VerticalBarChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>
465
498
  onBlur: _onBarLeave,
466
499
  fill: point.color && !useSingleColor ? point.color : colorScale(point.y),
467
500
  tabIndex: point.legend !== '' ? 0 : undefined,
468
- opacity: shouldHighlight ? '1' : '0.1'
469
- }), _renderBarLabel(xPoint, yPoint, point.y, point.legend));
501
+ opacity: shouldHighlight ? 1 : 0.1,
502
+ rx: props.roundCorners ? 3 : 0
503
+ }), _renderBarLabel(xPoint, yPoint, point.y, point.legend, isHeightNegative));
470
504
  });
471
505
  // Removing un wanted tooltip div from DOM, when prop not provided.
472
506
  if (!props.showXAxisLablesTooltip) {
@@ -496,30 +530,35 @@ const VerticalBarChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>
496
530
  function _createStringBars(containerHeight, containerWidth, xElement) {
497
531
  const { xBarScale, yBarScale } = _getScales(containerHeight, containerWidth);
498
532
  const colorScale = _createColors();
533
+ const yReferencePoint = _yMax < 0 ? _yMax : 0;
499
534
  const bars = _points.map((point, index)=>{
500
- const barHeight = Math.max(yBarScale(point.y), 0);
501
- let adjustedBarHeight = 0;
502
- if (barHeight <= 0) {
535
+ const shouldHighlight = _legendHighlighted(point.legend) || _noLegendHighlighted() ? true : false;
536
+ let barHeight = yBarScale(point.y) - yBarScale(yReferencePoint);
537
+ const isHeightNegative = barHeight < 0;
538
+ barHeight = Math.abs(barHeight);
539
+ // Calculate threshold for minimum visible bar height
540
+ const minBarHeight = _calculateMinBarHeight(_yMin, _yMax, yReferencePoint, yBarScale);
541
+ let adjustedBarHeight = barHeight;
542
+ if (barHeight === 0) {
503
543
  return /*#__PURE__*/ _react.createElement(_react.Fragment, {
504
- key: point.x instanceof Date ? point.x.getTime() : point.x
544
+ key: point.x
505
545
  }, " ");
506
- } else if (barHeight <= Math.ceil(yBarScale(_yMax) / 100.0)) {
507
- adjustedBarHeight = Math.ceil(yBarScale(_yMax) / 100.0);
508
- } else {
509
- adjustedBarHeight = barHeight;
546
+ } else if (barHeight <= minBarHeight) {
547
+ adjustedBarHeight = minBarHeight;
510
548
  }
511
549
  const xPoint = xBarScale(point.x);
512
- const yPoint = containerHeight - margins.bottom - adjustedBarHeight;
550
+ const yPoint = containerHeight - margins.bottom - (isHeightNegative ? -1 * adjustedBarHeight : adjustedBarHeight) - yBarScale(yReferencePoint);
551
+ const baselineHeight = containerHeight - margins.bottom - yBarScale(yReferencePoint);
513
552
  // Setting the bar width here is safe because there are no dependencies earlier in the code
514
553
  // that rely on the width of bars in vertical bar charts with string x-axis.
515
554
  _barWidth = (0, _index1.getBarWidth)(props.barWidth, props.maxBarWidth, xBarScale.bandwidth());
516
555
  return /*#__PURE__*/ _react.createElement("g", {
517
- key: point.x instanceof Date ? point.x.getTime() : point.x,
556
+ key: point.x instanceof Date ? `${point.x.getTime()}_${index}` : `${point.x}_${index}`,
518
557
  transform: `translate(${0.5 * (xBarScale.bandwidth() - _barWidth)}, 0)`
519
558
  }, /*#__PURE__*/ _react.createElement("rect", {
520
559
  id: `${_vbcBarId}-${index}`,
521
560
  x: xPoint,
522
- y: yPoint,
561
+ y: !isHeightNegative ? yPoint : baselineHeight,
523
562
  width: _barWidth,
524
563
  height: adjustedBarHeight,
525
564
  "aria-label": _getAriaLabel(point),
@@ -531,11 +570,13 @@ const VerticalBarChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>
531
570
  onMouseOver: (event)=>_onBarHover(point, colorScale(point.y), event),
532
571
  onMouseLeave: _onBarLeave,
533
572
  onBlur: _onBarLeave,
534
- "data-is-focusable": !props.hideTooltip,
573
+ "data-is-focusable": !props.hideTooltip && shouldHighlight,
535
574
  onFocus: _onBarFocus.bind(point, index, colorScale(point.y)),
536
575
  fill: point.color ? point.color : colorScale(point.y),
537
- tabIndex: point.legend !== '' ? 0 : undefined
538
- }), _renderBarLabel(xPoint, yPoint, point.y, point.legend));
576
+ tabIndex: point.legend !== '' ? 0 : undefined,
577
+ rx: props.roundCorners ? 3 : 0,
578
+ opacity: shouldHighlight ? 1 : 0.1
579
+ }), _renderBarLabel(xPoint, yPoint, point.y, point.legend, isHeightNegative));
539
580
  });
540
581
  // Removing un wanted tooltip div from DOM, when prop not provided.
541
582
  if (!props.showXAxisLablesTooltip) {
@@ -567,28 +608,32 @@ const VerticalBarChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>
567
608
  const { useSingleColor = false } = props;
568
609
  const { xBarScale, yBarScale } = _getScales(containerHeight, containerWidth);
569
610
  const colorScale = _createColors();
611
+ const yReferencePoint = _yMax < 0 ? _yMax : 0;
570
612
  const bars = _points.map((point, index)=>{
571
613
  const shouldHighlight = _legendHighlighted(point.legend) || _noLegendHighlighted() ? true : false;
572
- const barHeight = Math.max(yBarScale(point.y), 0);
573
- let adjustedBarHeight = 0;
574
- if (barHeight <= 0) {
614
+ let barHeight = yBarScale(point.y) - yBarScale(yReferencePoint);
615
+ const isHeightNegative = barHeight < 0;
616
+ barHeight = Math.abs(barHeight);
617
+ // Calculate threshold for minimum visible bar height
618
+ const minBarHeight = _calculateMinBarHeight(_yMin, _yMax, yReferencePoint, yBarScale);
619
+ let adjustedBarHeight = barHeight;
620
+ if (barHeight === 0) {
575
621
  return /*#__PURE__*/ _react.createElement(_react.Fragment, {
576
- key: point.x instanceof Date ? point.x.getTime() : point.x
622
+ key: point.x
577
623
  }, " ");
578
- } else if (barHeight <= Math.ceil(yBarScale(_yMax) / 100.0)) {
579
- adjustedBarHeight = Math.ceil(yBarScale(_yMax) / 100.0);
580
- } else {
581
- adjustedBarHeight = barHeight;
624
+ } else if (barHeight <= minBarHeight) {
625
+ adjustedBarHeight = minBarHeight;
582
626
  }
583
627
  const xPoint = xBarScale(point.x) - _barWidth / 2;
584
- const yPoint = containerHeight - margins.bottom - adjustedBarHeight;
628
+ const yPoint = containerHeight - margins.bottom - (isHeightNegative ? -1 * adjustedBarHeight : adjustedBarHeight) - yBarScale(yReferencePoint);
629
+ const baselineHeight = containerHeight - margins.bottom - yBarScale(yReferencePoint);
585
630
  return /*#__PURE__*/ _react.createElement("g", {
586
- key: point.x instanceof Date ? point.x.getTime() : point.x
631
+ key: point.x instanceof Date ? `${point.x.getTime()}_${index}` : `${point.x}_${index}`
587
632
  }, /*#__PURE__*/ _react.createElement("rect", {
588
633
  id: `${_vbcBarId}-${index}`,
589
634
  x: xPoint,
590
635
  className: classes.opacityChangeOnHover,
591
- y: yPoint,
636
+ y: !isHeightNegative ? yPoint : baselineHeight,
592
637
  width: _barWidth,
593
638
  "data-is-focusable": !props.hideTooltip && shouldHighlight,
594
639
  height: adjustedBarHeight,
@@ -603,8 +648,10 @@ const VerticalBarChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>
603
648
  onFocus: _onBarFocus.bind(point, index, colorScale(point.y)),
604
649
  onBlur: _onBarLeave,
605
650
  fill: point.color && !useSingleColor ? point.color : colorScale(point.y),
606
- tabIndex: point.legend !== '' ? 0 : undefined
607
- }), _renderBarLabel(xPoint, yPoint, point.y, point.legend));
651
+ tabIndex: point.legend !== '' ? 0 : undefined,
652
+ rx: props.roundCorners ? 3 : 0,
653
+ opacity: shouldHighlight ? 1 : 0.1
654
+ }), _renderBarLabel(xPoint, yPoint, point.y, point.legend, isHeightNegative));
608
655
  });
609
656
  // Removing un wanted tooltip div from DOM, when prop not provided.
610
657
  if (!props.showXAxisLablesTooltip) {
@@ -631,36 +678,30 @@ const VerticalBarChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>
631
678
  }
632
679
  return bars;
633
680
  }
634
- function _onLegendClick(legendTitle) {
635
- if (selectedLegend === legendTitle) {
636
- setSelectedLegend('');
637
- } else {
638
- setSelectedLegend(legendTitle);
639
- }
640
- }
641
681
  function _onLegendHover(legendTitle) {
642
682
  setActiveLegend(legendTitle);
643
683
  }
644
684
  function _onLegendLeave() {
645
- setActiveLegend('');
685
+ setActiveLegend(undefined);
646
686
  }
647
687
  function _getLegendData(data) {
648
688
  const { useSingleColor } = props;
649
689
  const { lineLegendText, lineLegendColor = _reacttheme.tokens.colorPaletteYellowForeground1 } = props;
650
690
  const actions = [];
691
+ const mapLegendToColor = {};
651
692
  data.forEach((point, _index)=>{
652
693
  // eslint-disable-next-line @typescript-eslint/no-shadow
653
694
  const color = !useSingleColor ? point.color : _createColors()(1);
695
+ mapLegendToColor[point.legend] = color;
696
+ });
697
+ Object.entries(mapLegendToColor).forEach(([legendTitle, color])=>{
654
698
  // mapping data to the format Legends component needs
655
699
  const legend = {
656
- title: point.legend,
700
+ title: legendTitle,
657
701
  color,
658
- action: ()=>{
659
- _onLegendClick(point.legend);
660
- },
661
702
  hoverAction: ()=>{
662
703
  _handleChartMouseLeave();
663
- _onLegendHover(point.legend);
704
+ _onLegendHover(legendTitle);
664
705
  },
665
706
  onMouseOutAction: ()=>{
666
707
  _onLegendLeave();
@@ -672,9 +713,6 @@ const VerticalBarChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>
672
713
  const lineLegend = {
673
714
  title: lineLegendText,
674
715
  color: lineLegendColor,
675
- action: ()=>{
676
- _onLegendClick(lineLegendText);
677
- },
678
716
  hoverAction: ()=>{
679
717
  _handleChartMouseLeave();
680
718
  _onLegendHover(lineLegendText);
@@ -690,14 +728,28 @@ const VerticalBarChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>
690
728
  legends: actions,
691
729
  enabledWrapLines: props.enabledLegendsWrapLines,
692
730
  overflowText: props.legendsOverflowText,
693
- ...props.legendProps
731
+ ...props.legendProps,
732
+ selectedLegends: selectedLegends,
733
+ onChange: _onLegendSelectionChange
694
734
  });
695
735
  return legends;
696
736
  }
737
+ function _onLegendSelectionChange(legendsSelected, event, currentLegend) {
738
+ var _props_legendProps, _props_legendProps1;
739
+ if ((_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.canSelectMultipleLegends) {
740
+ setSelectedLegends(legendsSelected);
741
+ } else {
742
+ setSelectedLegends(legendsSelected.slice(-1));
743
+ }
744
+ if ((_props_legendProps1 = props.legendProps) === null || _props_legendProps1 === void 0 ? void 0 : _props_legendProps1.onChange) {
745
+ props.legendProps.onChange(legendsSelected, event, currentLegend);
746
+ }
747
+ }
697
748
  function _getAxisData(yAxisData) {
698
749
  if (yAxisData && yAxisData.yAxisDomainValues.length) {
699
750
  const { yAxisDomainValues: domainValue } = yAxisData;
700
751
  _yMax = Math.max(domainValue[domainValue.length - 1], props.yMaxValue || 0);
752
+ _yMin = Math.min(domainValue[0], props.yMinValue || 0);
701
753
  }
702
754
  }
703
755
  /**
@@ -706,12 +758,17 @@ const VerticalBarChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>
706
758
  * 1. selection: if the user clicks on it
707
759
  * 2. hovering: if there is no selected legend and the user hovers over it
708
760
  */ function _legendHighlighted(legendTitle) {
709
- return selectedLegend === legendTitle || selectedLegend === '' && activeLegend === legendTitle;
761
+ return _getHighlightedLegend().includes(legendTitle);
710
762
  }
711
763
  /**
712
764
  * This function checks if none of the legends is selected or hovered.
713
765
  */ function _noLegendHighlighted() {
714
- return selectedLegend === '' && activeLegend === '';
766
+ return _getHighlightedLegend().length === 0;
767
+ }
768
+ function _getHighlightedLegend() {
769
+ return selectedLegends.length > 0 ? selectedLegends : activeLegend ? [
770
+ activeLegend
771
+ ] : [];
715
772
  }
716
773
  function _getAriaLabel(point) {
717
774
  var _point_lineData, _point_lineData1, _point_callOutAccessibilityData;
@@ -722,13 +779,13 @@ const VerticalBarChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>
722
779
  const lineYValue = ((_point_lineData = point.lineData) === null || _point_lineData === void 0 ? void 0 : _point_lineData.yAxisCalloutData) || ((_point_lineData1 = point.lineData) === null || _point_lineData1 === void 0 ? void 0 : _point_lineData1.y);
723
780
  return ((_point_callOutAccessibilityData = point.callOutAccessibilityData) === null || _point_callOutAccessibilityData === void 0 ? void 0 : _point_callOutAccessibilityData.ariaLabel) || `${xValue}. ` + (legend ? `${legend}, ` : '') + `${yValue}.` + (typeof lineYValue !== 'undefined' ? ` ${lineLegend}, ${lineYValue}.` : '');
724
781
  }
725
- function _renderBarLabel(xPoint, yPoint, barValue, legend) {
782
+ function _renderBarLabel(xPoint, yPoint, barValue, legend, isNegativeBar) {
726
783
  if (props.hideLabels || _barWidth < 16 || !(_legendHighlighted(legend) || _noLegendHighlighted())) {
727
784
  return null;
728
785
  }
729
786
  return /*#__PURE__*/ _react.createElement("text", {
730
787
  x: xPoint + _barWidth / 2,
731
- y: yPoint - 6,
788
+ y: isNegativeBar ? yPoint + 12 : yPoint - 6,
732
789
  textAnchor: "middle",
733
790
  className: classes.barLabel,
734
791
  "aria-hidden": true
@@ -737,13 +794,13 @@ const VerticalBarChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>
737
794
  function _getDomainMargins(containerWidth) {
738
795
  _domainMargin = MIN_DOMAIN_MARGIN;
739
796
  /** Total width available to render the bars */ const totalWidth = containerWidth - (margins.left + MIN_DOMAIN_MARGIN) - (margins.right + MIN_DOMAIN_MARGIN);
797
+ /** Rate at which the space between the bars changes wrt the bar width */ const barGapRate = _xAxisInnerPadding / (1 - _xAxisInnerPadding);
740
798
  if (_xAxisType === _index1.XAxisTypes.StringAxis) {
741
799
  if ((0, _index1.isScalePaddingDefined)(props.xAxisOuterPadding, props.xAxisPadding)) {
742
800
  // Setting the domain margin for string x-axis to 0 because the xAxisOuterPadding prop is now available
743
801
  // to adjust the space before the first bar and after the last bar.
744
802
  _domainMargin = 0;
745
803
  } else if (props.barWidth !== 'auto') {
746
- /** Rate at which the space between the bars changes wrt the bar width */ const barGapRate = _xAxisInnerPadding / (1 - _xAxisInnerPadding);
747
804
  // Update the bar width so that when CartesianChart rerenders,
748
805
  // the following calculations don't use the previous bar width.
749
806
  _barWidth = (0, _index1.getBarWidth)(props.barWidth, props.maxBarWidth);
@@ -752,10 +809,29 @@ const VerticalBarChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>
752
809
  // Center align the chart by setting equal left and right margins for domain
753
810
  _domainMargin = MIN_DOMAIN_MARGIN + (totalWidth - reqWidth) / 2;
754
811
  }
812
+ } else if (props.mode === 'plotly' && _xAxisLabels.length > 1) {
813
+ // Calculate the remaining width after rendering bars at their maximum allowable width
814
+ const bandwidth = totalWidth / (_xAxisLabels.length + (_xAxisLabels.length - 1) * barGapRate);
815
+ const barWidth = (0, _index1.getBarWidth)(props.barWidth, props.maxBarWidth, bandwidth);
816
+ let reqWidth = (_xAxisLabels.length + (_xAxisLabels.length - 1) * barGapRate) * barWidth;
817
+ const margin1 = (totalWidth - reqWidth) / 2;
818
+ // Calculate the remaining width after accounting for the space required to render x-axis labels
819
+ const step = (0, _index1.calculateLongestLabelWidth)(_xAxisLabels) + 20;
820
+ reqWidth = (_xAxisLabels.length - _xAxisInnerPadding) * step;
821
+ const margin2 = (totalWidth - reqWidth) / 2;
822
+ _domainMargin = MIN_DOMAIN_MARGIN + Math.max(0, Math.min(margin1, margin2));
755
823
  }
756
824
  } else {
757
825
  var _props_data;
758
- const data = ((_props_data = props.data) === null || _props_data === void 0 ? void 0 : _props_data.map((point)=>point.x)) || [];
826
+ const uniqueX = {};
827
+ (_props_data = props.data) === null || _props_data === void 0 ? void 0 : _props_data.forEach((point)=>{
828
+ if (point.x instanceof Date) {
829
+ uniqueX[point.x.getTime()] = point.x;
830
+ } else {
831
+ uniqueX[point.x] = point.x;
832
+ }
833
+ });
834
+ const data = Object.values(uniqueX);
759
835
  _barWidth = (0, _index1.getBarWidth)(props.barWidth, props.maxBarWidth, (0, _index1.calculateAppropriateBarWidth)(data, totalWidth));
760
836
  _domainMargin = MIN_DOMAIN_MARGIN + _barWidth / 2;
761
837
  }
@@ -766,7 +842,7 @@ const VerticalBarChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>
766
842
  };
767
843
  }
768
844
  function _isChartEmpty() {
769
- return _points.length === 0 || (0, _d3array.max)(_points, (point)=>point.y) <= 0 && !_isHavingLine;
845
+ return _points.length === 0 || _points.every((point)=>point.y === 0) && !_isHavingLine;
770
846
  }
771
847
  function updatePosition(newX, newY) {
772
848
  const threshold = 1; // Set a threshold for movement
@@ -785,11 +861,12 @@ const VerticalBarChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>
785
861
  _adjustProps();
786
862
  _xAxisLabels = _points.map((point)=>point.x);
787
863
  _yMax = Math.max((0, _d3array.max)(_points, (point)=>point.y), props.yMaxValue || 0);
864
+ _yMin = Math.min((0, _d3array.min)(_points, (point)=>point.y), props.yMinValue || 0);
788
865
  const legendBars = _getLegendData(_points);
789
866
  var _props_culture;
790
867
  const calloutProps = {
791
868
  ..._isHavingLine && {
792
- YValueHover: YValueHover,
869
+ YValueHover: hoveredYValues,
793
870
  hoverXValue: hoverXValue
794
871
  },
795
872
  color: color,
@@ -800,7 +877,7 @@ const VerticalBarChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>
800
877
  ...(0, _index1.getAccessibleDataObject)(callOutAccessibilityData),
801
878
  clickPosition: clickPosition,
802
879
  isPopoverOpen: isPopoverOpen,
803
- isCalloutForStack: _isHavingLine && _noLegendHighlighted(),
880
+ isCalloutForStack: _isHavingLine && (_noLegendHighlighted() || _getHighlightedLegend().length > 1),
804
881
  culture: (_props_culture = props.culture) !== null && _props_culture !== void 0 ? _props_culture : 'en-us',
805
882
  isCartesian: true,
806
883
  customCallout: {