@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
@@ -0,0 +1,915 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "VerticalStackedBarChart", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return VerticalStackedBarChart;
9
+ }
10
+ });
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
13
+ const _d3array = require("d3-array");
14
+ const _d3selection = require("d3-selection");
15
+ const _useVerticalStackedBarChartStylesstyles = require("./useVerticalStackedBarChartStyles.styles");
16
+ const _d3scale = require("d3-scale");
17
+ const _reactutilities = require("@fluentui/react-utilities");
18
+ const _reacttheme = require("@fluentui/react-theme");
19
+ const _index = require("../../index");
20
+ const _index1 = require("../../utilities/index");
21
+ const barGapMultiplier = 0.2;
22
+ const barGapMin = 1;
23
+ const MIN_DOMAIN_MARGIN = 8;
24
+ var CircleVisbility;
25
+ (function(CircleVisbility) {
26
+ CircleVisbility["show"] = "visibility";
27
+ CircleVisbility["hide"] = "hidden";
28
+ })(CircleVisbility || (CircleVisbility = {}));
29
+ const VerticalStackedBarChart = (props)=>{
30
+ var _props_legendProps;
31
+ const _isRtl = (0, _index1.useRtl)();
32
+ const _createLegendsForLine = (data)=>_getLineLegends(data);
33
+ const _tooltipId = (0, _reactutilities.useId)('VSBCTooltipId_');
34
+ const _emptyChartId = (0, _reactutilities.useId)('_VSBC_empty');
35
+ let _points = [];
36
+ let _dataset;
37
+ let _xAxisLabels = [];
38
+ let _bars;
39
+ let _xAxisType = props.data && props.data.length > 0 ? (0, _index1.getTypeOfAxis)(props.data[0].xAxisPoint, true) : _index1.XAxisTypes.StringAxis;
40
+ let _barWidth = 0;
41
+ let _colors;
42
+ let _margins;
43
+ let _lineObject;
44
+ let _yMax;
45
+ let _calloutAnchorPoint;
46
+ let _domainMargin = MIN_DOMAIN_MARGIN;
47
+ let _xAxisInnerPadding = 0;
48
+ let _xAxisOuterPadding = 0;
49
+ const cartesianChartRef = _react.useRef(null);
50
+ const [selectedLegends, setSelectedLegends] = _react.useState(((_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.selectedLegends) || []);
51
+ const [activeLegend, setActiveLegend] = _react.useState(undefined);
52
+ const [dataForHoverCard, setDataForHoverCard] = _react.useState(0);
53
+ const [color, setColor] = _react.useState('');
54
+ const [hoverXValue, setHoverXValue] = _react.useState('');
55
+ const [YValueHover, setYValueHover] = _react.useState([]);
56
+ const [xCalloutValue, setXCalloutValue] = _react.useState('');
57
+ const [yCalloutValue, setYCalloutValue] = _react.useState('');
58
+ const [activeXAxisDataPoint, setActiveXAxisDataPoint] = _react.useState('');
59
+ const [calloutLegend, setCalloutLegend] = _react.useState('');
60
+ const [stackCalloutProps, setStackCalloutProps] = _react.useState();
61
+ const [dataPointCalloutProps, setDataPointCalloutProps] = _react.useState();
62
+ const [callOutAccessibilityData, setCallOutAccessibilityData] = _react.useState();
63
+ const [clickPosition, setClickPosition] = _react.useState({
64
+ x: 0,
65
+ y: 0
66
+ });
67
+ const [isPopoverOpen, setPopoverOpen] = _react.useState(false);
68
+ const prevPropsRef = _react.useRef(null);
69
+ _react.useEffect(()=>{
70
+ if (prevPropsRef.current) {
71
+ var _prevProps_legendProps, _props_legendProps;
72
+ const prevProps = prevPropsRef.current;
73
+ 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)) {
74
+ var _props_legendProps1;
75
+ setSelectedLegends(((_props_legendProps1 = props.legendProps) === null || _props_legendProps1 === void 0 ? void 0 : _props_legendProps1.selectedLegends) || []);
76
+ }
77
+ if (prevProps.height !== props.height || prevProps.width !== props.width || prevProps.data !== props.data) {
78
+ _adjustProps();
79
+ _dataset = _createDataSetLayer();
80
+ }
81
+ }
82
+ prevPropsRef.current = props;
83
+ }, [
84
+ props
85
+ ]);
86
+ _react.useImperativeHandle(props.componentRef, ()=>{
87
+ var _cartesianChartRef_current;
88
+ var _cartesianChartRef_current_chartContainer;
89
+ return {
90
+ 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
91
+ };
92
+ }, []);
93
+ function _getLegendData(data, lineLegends) {
94
+ if (props.hideLegend) {
95
+ return /*#__PURE__*/ _react.createElement(_react.Fragment, null);
96
+ }
97
+ const defaultPalette = [
98
+ (0, _index1.getColorFromToken)(_index1.DataVizPalette.color6),
99
+ (0, _index1.getColorFromToken)(_index1.DataVizPalette.color1),
100
+ (0, _index1.getColorFromToken)(_index1.DataVizPalette.color5),
101
+ (0, _index1.getColorFromToken)(_index1.DataVizPalette.color7),
102
+ (0, _index1.getColorFromToken)(_index1.DataVizPalette.color10)
103
+ ];
104
+ const actions = [];
105
+ const { allowHoverOnLegend = true } = props;
106
+ data.forEach((singleChartData)=>{
107
+ singleChartData.chartData.forEach((point)=>{
108
+ const color = point.color ? point.color : defaultPalette[Math.floor(Math.random() * 4 + 1)];
109
+ const checkSimilarLegends = actions.filter((leg)=>leg.title === point.legend && leg.color === color);
110
+ if (checkSimilarLegends.length > 0) {
111
+ return;
112
+ }
113
+ const legend = {
114
+ title: point.legend,
115
+ color,
116
+ hoverAction: allowHoverOnLegend ? ()=>{
117
+ _handleChartMouseLeave();
118
+ _onLegendHover(point.legend);
119
+ } : undefined,
120
+ onMouseOutAction: allowHoverOnLegend ? ()=>_onLegendLeave() : undefined
121
+ };
122
+ actions.push(legend);
123
+ });
124
+ });
125
+ const legendsOfLine = [];
126
+ if (lineLegends && lineLegends.length > 0) {
127
+ lineLegends.forEach((point)=>{
128
+ const legend = {
129
+ title: point.title,
130
+ color: point.color,
131
+ isLineLegendInBarChart: true,
132
+ hoverAction: allowHoverOnLegend ? ()=>{
133
+ _handleChartMouseLeave();
134
+ _onLegendHover(point.title);
135
+ } : undefined,
136
+ onMouseOutAction: allowHoverOnLegend ? ()=>_onLegendLeave() : undefined
137
+ };
138
+ legendsOfLine.push(legend);
139
+ });
140
+ }
141
+ const totalLegends = legendsOfLine.concat(actions);
142
+ return /*#__PURE__*/ _react.createElement(_index.Legends, {
143
+ legends: totalLegends,
144
+ enabledWrapLines: props.enabledLegendsWrapLines,
145
+ overflowText: props.legendsOverflowText,
146
+ ...props.legendProps,
147
+ onChange: _onLegendSelectionChange
148
+ });
149
+ }
150
+ function _getHighlightedLegend() {
151
+ return selectedLegends.length > 0 ? selectedLegends : activeLegend ? [
152
+ activeLegend
153
+ ] : [];
154
+ }
155
+ function _lineHoverOut() {
156
+ setPopoverOpen(false);
157
+ setXCalloutValue('');
158
+ setYCalloutValue('');
159
+ setActiveXAxisDataPoint('');
160
+ setColor('');
161
+ }
162
+ function _lineHoverFocus(lineData) {
163
+ setPopoverOpen(true);
164
+ setXCalloutValue(`${lineData.xItem.xAxisPoint}`);
165
+ setYCalloutValue(`${lineData.yAxisCalloutData || lineData.data || lineData.y}`);
166
+ setActiveXAxisDataPoint(lineData.xItem.xAxisPoint);
167
+ setColor(lineData.color);
168
+ }
169
+ function _onStackHoverFocus(stack, mouseEvent) {
170
+ var _stack_lineData;
171
+ let clientX = 0;
172
+ let clientY = 0;
173
+ if ('clientX' in mouseEvent) {
174
+ clientX = mouseEvent.clientX;
175
+ clientY = mouseEvent.clientY;
176
+ } else {
177
+ // Handle case where mouseEvent is an SVGGElement
178
+ const boundingRect = mouseEvent.getBoundingClientRect();
179
+ clientX = boundingRect.left + boundingRect.width / 2;
180
+ clientY = boundingRect.top + boundingRect.height / 2;
181
+ }
182
+ if (!_noLegendHighlighted()) {
183
+ var _stack_lineData1;
184
+ stack = {
185
+ ...stack,
186
+ chartData: stack.chartData.filter((dataPoint)=>_isLegendHighlighted(dataPoint.legend)),
187
+ lineData: (_stack_lineData1 = stack.lineData) === null || _stack_lineData1 === void 0 ? void 0 : _stack_lineData1.filter((dataPoint)=>_isLegendHighlighted(dataPoint.legend))
188
+ };
189
+ }
190
+ const lineData = stack.lineData;
191
+ const isLinesPresent = lineData !== undefined && lineData.length > 0;
192
+ if (isLinesPresent) {
193
+ lineData.forEach((item)=>{
194
+ item.data = item.data || item.y;
195
+ item.shouldDrawBorderBottom = true;
196
+ });
197
+ }
198
+ _updatePosition(clientX, clientY);
199
+ var _stack_lineData_length;
200
+ setPopoverOpen(stack.chartData.length > 0 || ((_stack_lineData_length = (_stack_lineData = stack.lineData) === null || _stack_lineData === void 0 ? void 0 : _stack_lineData.length) !== null && _stack_lineData_length !== void 0 ? _stack_lineData_length : 0) > 0);
201
+ setYValueHover(isLinesPresent ? [
202
+ ...lineData.sort((a, b)=>a.data < b.data ? 1 : -1),
203
+ ...stack.chartData.slice().reverse()
204
+ ] : stack.chartData.slice().reverse());
205
+ setHoverXValue(stack.xAxisPoint instanceof Date ? (0, _index1.formatDate)(stack.xAxisPoint, props.useUTC) : stack.xAxisPoint);
206
+ setStackCalloutProps(stack);
207
+ setActiveXAxisDataPoint(stack.xAxisPoint);
208
+ setCallOutAccessibilityData(stack.stackCallOutAccessibilityData);
209
+ }
210
+ function _handleChartMouseLeave() {
211
+ _calloutAnchorPoint = null;
212
+ setPopoverOpen(false);
213
+ setActiveXAxisDataPoint('');
214
+ }
215
+ const _onClick = (data, mouseEvent)=>{
216
+ var _props_onBarClick;
217
+ (_props_onBarClick = props.onBarClick) === null || _props_onBarClick === void 0 ? void 0 : _props_onBarClick.call(props, mouseEvent, data);
218
+ props.href ? window.location.href = props.href : '';
219
+ };
220
+ function _adjustProps() {
221
+ _points = props.data || [];
222
+ _barWidth = (0, _index1.getBarWidth)(props.barWidth, props.maxBarWidth);
223
+ const defaultColors = [
224
+ (0, _index1.getColorFromToken)(_index1.DataVizPalette.color6),
225
+ (0, _index1.getColorFromToken)(_index1.DataVizPalette.color1),
226
+ (0, _index1.getColorFromToken)(_index1.DataVizPalette.color5),
227
+ (0, _index1.getColorFromToken)(_index1.DataVizPalette.color7),
228
+ (0, _index1.getColorFromToken)(_index1.DataVizPalette.color10)
229
+ ];
230
+ _colors = defaultColors;
231
+ _xAxisType = (0, _index1.getTypeOfAxis)(props.data[0].xAxisPoint, true);
232
+ _lineObject = _getFormattedLineData(props.data);
233
+ _xAxisInnerPadding = (0, _index1.getScalePadding)(props.xAxisInnerPadding, props.xAxisPadding, 2 / 3);
234
+ _xAxisOuterPadding = (0, _index1.getScalePadding)(props.xAxisOuterPadding, props.xAxisPadding, 0);
235
+ }
236
+ function _createDataSetLayer() {
237
+ const tempArr = [];
238
+ const dataset = _points.map((singlePointData)=>{
239
+ let total = 0;
240
+ singlePointData.chartData.forEach((point)=>{
241
+ total = total + point.data;
242
+ });
243
+ tempArr.push(singlePointData.xAxisPoint);
244
+ return {
245
+ x: singlePointData.xAxisPoint,
246
+ y: total
247
+ };
248
+ });
249
+ _xAxisLabels = tempArr;
250
+ return dataset;
251
+ }
252
+ function _onLegendHover(legendTitle) {
253
+ setActiveLegend(legendTitle);
254
+ }
255
+ function _onLegendLeave() {
256
+ setActiveLegend(undefined);
257
+ }
258
+ function _onLegendSelectionChange(_selectedLegends, event, currentLegend) {
259
+ var _props_legendProps, _props_legendProps1;
260
+ if ((_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.canSelectMultipleLegends) {
261
+ setSelectedLegends(_selectedLegends);
262
+ } else {
263
+ setSelectedLegends(_selectedLegends.slice(-1));
264
+ }
265
+ if ((_props_legendProps1 = props.legendProps) === null || _props_legendProps1 === void 0 ? void 0 : _props_legendProps1.onChange) {
266
+ props.legendProps.onChange(_selectedLegends, event, currentLegend);
267
+ }
268
+ }
269
+ function _getMargins(margins) {
270
+ _margins = margins;
271
+ }
272
+ function _getGraphData(xScale, yScale, containerHeight, containerWidth, xElement) {
273
+ const { xBarScale, yBarScale } = _getScales(containerHeight, containerWidth);
274
+ return _bars = _createBar(xBarScale, yBarScale, containerHeight, xElement);
275
+ }
276
+ function _getAxisData(yAxisData) {
277
+ if (yAxisData && yAxisData.yAxisDomainValues.length) {
278
+ const { yAxisDomainValues: domainValue } = yAxisData;
279
+ _yMax = Math.max(domainValue[domainValue.length - 1], props.yMaxValue || 0);
280
+ }
281
+ }
282
+ /**
283
+ * This function checks if the given legend is highlighted or not.
284
+ * A legend can be highlighted in 2 ways:
285
+ * 1. selection: if the user clicks on it
286
+ * 2. hovering: if there is no selected legend and the user hovers over it
287
+ */ function _isLegendHighlighted(legendTitle) {
288
+ return _getHighlightedLegend().includes(legendTitle);
289
+ }
290
+ /**
291
+ * This function checks if none of the legends is selected or hovered.
292
+ */ function _noLegendHighlighted() {
293
+ return _getHighlightedLegend().length === 0;
294
+ }
295
+ function _getAriaLabel(singleChartData, point) {
296
+ var _point_callOutAccessibilityData;
297
+ if (!point) {
298
+ var _singleChartData_lineData, _singleChartData_stackCallOutAccessibilityData;
299
+ /** if shouldFocusWholeStack is true */ const xValue = singleChartData.xAxisCalloutData || (singleChartData.xAxisPoint instanceof Date ? (0, _index1.formatDate)(singleChartData.xAxisPoint) : singleChartData.xAxisPoint);
300
+ const pointValues = singleChartData.chartData.map((pt)=>{
301
+ const legend = pt.legend;
302
+ const yValue = pt.yAxisCalloutData || pt.data;
303
+ return `${legend}, ${yValue}.`;
304
+ }).join(' ');
305
+ const lineValues = (_singleChartData_lineData = singleChartData.lineData) === null || _singleChartData_lineData === void 0 ? void 0 : _singleChartData_lineData.map((ln)=>{
306
+ const legend = ln.legend;
307
+ const yValue = ln.yAxisCalloutData || ln.data || ln.y;
308
+ return `${legend}, ${yValue}.`;
309
+ }).join(' ');
310
+ return ((_singleChartData_stackCallOutAccessibilityData = singleChartData.stackCallOutAccessibilityData) === null || _singleChartData_stackCallOutAccessibilityData === void 0 ? void 0 : _singleChartData_stackCallOutAccessibilityData.ariaLabel) || `${xValue}. ${pointValues}` + (lineValues ? ` ${lineValues}` : '');
311
+ }
312
+ /** if shouldFocusWholeStack is false */ const xValue = singleChartData.xAxisCalloutData || point.xAxisCalloutData || (singleChartData.xAxisPoint instanceof Date ? (0, _index1.formatDate)(singleChartData.xAxisPoint) : singleChartData.xAxisPoint);
313
+ const legend = point.legend;
314
+ const yValue = point.yAxisCalloutData || point.data;
315
+ return ((_point_callOutAccessibilityData = point.callOutAccessibilityData) === null || _point_callOutAccessibilityData === void 0 ? void 0 : _point_callOutAccessibilityData.ariaLabel) || `${xValue}. ${legend}, ${yValue}.`;
316
+ }
317
+ function _getCustomizedCallout() {
318
+ const _isHavingLines = props.data.some((item)=>item.lineData && item.lineData.length > 0);
319
+ return props.onRenderCalloutPerStack ? props.onRenderCalloutPerStack(stackCalloutProps) : props.onRenderCalloutPerDataPoint && !_isHavingLines ? props.onRenderCalloutPerDataPoint(dataPointCalloutProps, _renderCallout) : null;
320
+ }
321
+ function _toFocusWholeStack(_isHavingLines) {
322
+ const { isCalloutForStack = false } = props;
323
+ let shouldFocusStackOnly = false;
324
+ if (_isHavingLines) {
325
+ if (_getHighlightedLegend().length === 1) {
326
+ shouldFocusStackOnly = false;
327
+ } else {
328
+ shouldFocusStackOnly = true;
329
+ }
330
+ } else {
331
+ shouldFocusStackOnly = isCalloutForStack;
332
+ }
333
+ return shouldFocusStackOnly;
334
+ }
335
+ function _getFormattedLineData(data) {
336
+ const linesData = [];
337
+ const formattedLineData = {};
338
+ data.forEach((item, index)=>{
339
+ if (item.lineData) {
340
+ item.lineData.forEach((line)=>{
341
+ linesData.push({
342
+ ...line,
343
+ index,
344
+ xItem: item
345
+ });
346
+ });
347
+ }
348
+ });
349
+ linesData.forEach((item)=>{
350
+ if (formattedLineData[item.legend]) {
351
+ formattedLineData[item.legend].push(item);
352
+ } else {
353
+ formattedLineData[item.legend] = [
354
+ item
355
+ ];
356
+ }
357
+ });
358
+ return formattedLineData;
359
+ }
360
+ function _getLineLegends(data) {
361
+ const lineObject = _lineObject;
362
+ const lineLegends = [];
363
+ Object.keys(lineObject).forEach((item)=>{
364
+ lineLegends.push({
365
+ title: item,
366
+ color: lineObject[item][0].color
367
+ });
368
+ });
369
+ return lineLegends;
370
+ }
371
+ function _createLines(xScale, yScale, containerHeight, containerWidth, secondaryYScale) {
372
+ var _props_lineOptions;
373
+ const lineObject = _getFormattedLineData(props.data);
374
+ const lines = [];
375
+ const borderForLines = [];
376
+ const dots = [];
377
+ //const { theme } = props;
378
+ const lineBorderWidth = ((_props_lineOptions = props.lineOptions) === null || _props_lineOptions === void 0 ? void 0 : _props_lineOptions.lineBorderWidth) ? Number.parseFloat(props.lineOptions.lineBorderWidth.toString()) : 0;
379
+ const xScaleBandwidthTranslate = _xAxisType !== _index1.XAxisTypes.StringAxis ? 0 : xScale.bandwidth() / 2;
380
+ Object.keys(lineObject).forEach((item, index)=>{
381
+ const shouldHighlight = _isLegendHighlighted(item) || _noLegendHighlighted();
382
+ for(let i = 1; i < lineObject[item].length; i++){
383
+ var _lineObject_item__lineOptions, _lineObject_item__lineOptions1, _lineObject_item__lineOptions2;
384
+ const x1 = xScale(lineObject[item][i - 1].xItem.xAxisPoint);
385
+ const useSecondaryYScale = lineObject[item][i - 1].useSecondaryYScale && lineObject[item][i].useSecondaryYScale && secondaryYScale;
386
+ const y1 = useSecondaryYScale ? secondaryYScale(lineObject[item][i - 1].y) : yScale(lineObject[item][i - 1].y);
387
+ const x2 = xScale(lineObject[item][i].xItem.xAxisPoint);
388
+ const y2 = useSecondaryYScale ? secondaryYScale(lineObject[item][i].y) : yScale(lineObject[item][i].y);
389
+ if (lineBorderWidth > 0) {
390
+ borderForLines.push(/*#__PURE__*/ _react.createElement("line", {
391
+ key: `${index}-${i}-BorderLine`,
392
+ x1: x1,
393
+ y1: y1,
394
+ x2: x2,
395
+ y2: y2,
396
+ opacity: shouldHighlight ? 1 : 0.1,
397
+ strokeWidth: 3 + lineBorderWidth * 2,
398
+ fill: "transparent",
399
+ strokeLinecap: "round",
400
+ stroke: _reacttheme.tokens.colorNeutralBackground1,
401
+ transform: `translate(${xScaleBandwidthTranslate}, 0)`
402
+ }));
403
+ }
404
+ var _lineObject_item__lineOptions_strokeWidth, _lineObject_item__lineOptions_strokeLinecap;
405
+ lines.push(/*#__PURE__*/ _react.createElement("line", {
406
+ key: `${index}-${i}-line`,
407
+ x1: x1,
408
+ y1: y1,
409
+ x2: x2,
410
+ y2: y2,
411
+ opacity: shouldHighlight ? 1 : 0.1,
412
+ strokeWidth: (_lineObject_item__lineOptions_strokeWidth = (_lineObject_item__lineOptions = lineObject[item][0].lineOptions) === null || _lineObject_item__lineOptions === void 0 ? void 0 : _lineObject_item__lineOptions.strokeWidth) !== null && _lineObject_item__lineOptions_strokeWidth !== void 0 ? _lineObject_item__lineOptions_strokeWidth : 3,
413
+ 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',
414
+ strokeDasharray: (_lineObject_item__lineOptions2 = lineObject[item][0].lineOptions) === null || _lineObject_item__lineOptions2 === void 0 ? void 0 : _lineObject_item__lineOptions2.strokeDasharray,
415
+ stroke: lineObject[item][i].color,
416
+ transform: `translate(${xScaleBandwidthTranslate}, 0)`,
417
+ ..._isLegendHighlighted(item) && {
418
+ onMouseOver: _lineHover.bind(lineObject[item][i - 1]),
419
+ onMouseLeave: _lineHoverOut
420
+ }
421
+ }));
422
+ }
423
+ });
424
+ Object.keys(lineObject).forEach((item, index)=>{
425
+ lineObject[item].forEach((circlePoint, subIndex)=>{
426
+ const circleRef = {
427
+ refElement: null
428
+ };
429
+ dots.push(/*#__PURE__*/ _react.createElement("circle", {
430
+ key: `${index}-${subIndex}-dot`,
431
+ cx: xScale(circlePoint.xItem.xAxisPoint),
432
+ cy: circlePoint.useSecondaryYScale && secondaryYScale ? secondaryYScale(circlePoint.y) : yScale(circlePoint.y),
433
+ onMouseOver: _isLegendHighlighted(item) ? (event)=>_lineHover(circlePoint, event) : (event)=>_onStackHover(circlePoint.xItem, event),
434
+ ..._isLegendHighlighted(item) && {
435
+ onMouseLeave: _lineHoverOut
436
+ },
437
+ r: _getCircleVisibilityAndRadius(circlePoint.xItem.xAxisPoint, circlePoint.legend).radius,
438
+ stroke: circlePoint.color,
439
+ fill: _reacttheme.tokens.colorNeutralBackground1,
440
+ strokeWidth: 3,
441
+ visibility: _getCircleVisibilityAndRadius(circlePoint.xItem.xAxisPoint, circlePoint.legend).visibility,
442
+ transform: `translate(${xScaleBandwidthTranslate}, 0)`,
443
+ "data-is-focusable": _isLegendHighlighted(item),
444
+ ref: (e)=>circleRef.refElement = e,
445
+ onFocus: _lineFocus.bind(circlePoint, circleRef),
446
+ onBlur: _lineHoverOut,
447
+ tabIndex: circlePoint.legend !== '' ? 0 : undefined
448
+ }));
449
+ });
450
+ });
451
+ return /*#__PURE__*/ _react.createElement(_react.Fragment, null, borderForLines, lines, dots);
452
+ }
453
+ function _getCircleVisibilityAndRadius(xAxisPoint, legend) {
454
+ if (!_noLegendHighlighted()) {
455
+ if (xAxisPoint === activeXAxisDataPoint && _isLegendHighlighted(legend)) {
456
+ return {
457
+ visibility: "visibility",
458
+ radius: 8
459
+ };
460
+ } else if (_isLegendHighlighted(legend)) {
461
+ return {
462
+ visibility: "visibility",
463
+ radius: 0.3
464
+ };
465
+ } else {
466
+ return {
467
+ visibility: "hidden",
468
+ radius: 0
469
+ };
470
+ }
471
+ } else {
472
+ return {
473
+ visibility: activeXAxisDataPoint === xAxisPoint ? "visibility" : "hidden",
474
+ radius: 8
475
+ };
476
+ }
477
+ }
478
+ function _renderCallout(props) {
479
+ var _props_culture;
480
+ return props ? /*#__PURE__*/ _react.createElement(_index.ChartPopover, {
481
+ culture: (_props_culture = props.culture) !== null && _props_culture !== void 0 ? _props_culture : 'en-us',
482
+ XValue: props.xAxisCalloutData,
483
+ xCalloutValue: xCalloutValue,
484
+ yCalloutValue: yCalloutValue,
485
+ clickPosition: clickPosition,
486
+ isPopoverOpen: isPopoverOpen,
487
+ legend: props.legend,
488
+ YValue: props.yAxisCalloutData,
489
+ color: props.color
490
+ }) : null;
491
+ }
492
+ function _onRectHover(xAxisPoint, point, color, mouseEvent) {
493
+ mouseEvent.persist();
494
+ _onRectFocusHover(xAxisPoint, point, color, mouseEvent);
495
+ }
496
+ function _onRectFocusHover(xAxisPoint, point, color, mouseEvent) {
497
+ let clientX = 0;
498
+ let clientY = 0;
499
+ if ('clientX' in mouseEvent) {
500
+ clientX = mouseEvent.clientX;
501
+ clientY = mouseEvent.clientY;
502
+ } else {
503
+ // Handle case where mouseEvent is an SVGGElement
504
+ const boundingRect = mouseEvent.getBoundingClientRect();
505
+ clientX = boundingRect.left + boundingRect.width / 2;
506
+ clientY = boundingRect.top + boundingRect.height / 2;
507
+ }
508
+ if ((_calloutAnchorPoint === null || _calloutAnchorPoint === void 0 ? void 0 : _calloutAnchorPoint.chartDataPoint) !== point || (_calloutAnchorPoint === null || _calloutAnchorPoint === void 0 ? void 0 : _calloutAnchorPoint.xAxisDataPoint) !== xAxisPoint) {
509
+ _calloutAnchorPoint = {
510
+ chartDataPoint: point,
511
+ xAxisDataPoint: `${xAxisPoint}`
512
+ };
513
+ _updatePosition(clientX, clientY);
514
+ setPopoverOpen(_noLegendHighlighted() || _isLegendHighlighted(point.legend));
515
+ setCalloutLegend(point.legend);
516
+ setDataForHoverCard(point.data);
517
+ setColor(color);
518
+ setXCalloutValue(point.xAxisCalloutData ? point.xAxisCalloutData : `${xAxisPoint}`);
519
+ setYCalloutValue(point.yAxisCalloutData);
520
+ setDataPointCalloutProps(point);
521
+ setCallOutAccessibilityData(point.callOutAccessibilityData);
522
+ }
523
+ }
524
+ function _lineHover(lineData, mouseEvent) {
525
+ mouseEvent.persist();
526
+ _lineHoverFocus(lineData);
527
+ }
528
+ function _lineFocus(lineData, ref) {
529
+ if (ref.refElement) {
530
+ _lineHoverFocus(lineData);
531
+ }
532
+ }
533
+ function _onStackHover(stack, mouseEvent) {
534
+ mouseEvent.persist();
535
+ _onStackHoverFocus(stack, mouseEvent);
536
+ }
537
+ function _onRectFocus(point, xAxisPoint, color, ref) {
538
+ if (ref.refElement) {
539
+ _onRectFocusHover(xAxisPoint, point, color, ref.refElement);
540
+ }
541
+ }
542
+ function _onStackFocus(stack, groupRef) {
543
+ if (groupRef.refElement) {
544
+ _onStackHoverFocus(stack, groupRef.refElement);
545
+ }
546
+ }
547
+ function _handleMouseOut() {
548
+ setPopoverOpen(false);
549
+ }
550
+ function _getBarGapAndScale(bars, yBarScale, defaultTotalHeight) {
551
+ const { barGapMax = 0 } = props;
552
+ // When displaying gaps between the bars, the height of each bar is
553
+ // adjusted so that the total of all bars is not changed by the gaps
554
+ const totalData = bars.reduce((iter, value)=>iter + Math.abs(value.data), 0);
555
+ const totalHeight = defaultTotalHeight !== null && defaultTotalHeight !== void 0 ? defaultTotalHeight : yBarScale(totalData);
556
+ let sumOfPercent = 0;
557
+ bars.forEach((point)=>{
558
+ let value = Math.abs(point.data) / totalData * 100;
559
+ if (value < 1 && value !== 0) {
560
+ value = 1;
561
+ }
562
+ sumOfPercent += value;
563
+ });
564
+ const scalingRatio = sumOfPercent !== 0 ? sumOfPercent / 100 : 1;
565
+ const gaps = barGapMax && bars.length - 1;
566
+ const gapHeight = gaps && Math.max(barGapMin, Math.min(barGapMax, totalHeight * barGapMultiplier / gaps));
567
+ const heightValueScale = (totalHeight - gapHeight * gaps) / (totalData * scalingRatio);
568
+ return {
569
+ gapHeight,
570
+ heightValueScale,
571
+ adjustedTotalHeight: sumOfPercent
572
+ };
573
+ }
574
+ function _getScales(containerHeight, containerWidth) {
575
+ const yMax = _yMax;
576
+ const yBarScale = (0, _d3scale.scaleLinear)().domain([
577
+ 0,
578
+ yMax
579
+ ]).range([
580
+ 0,
581
+ containerHeight - _margins.bottom - _margins.top
582
+ ]);
583
+ if (_xAxisType === _index1.XAxisTypes.NumericAxis) {
584
+ const xMax = (0, _d3array.max)(_dataset, (point)=>point.x);
585
+ const xMin = (0, _d3array.min)(_dataset, (point)=>point.x);
586
+ const xBarScale = (0, _d3scale.scaleLinear)().domain(_isRtl ? [
587
+ xMax,
588
+ xMin
589
+ ] : [
590
+ xMin,
591
+ xMax
592
+ ]).nice().range([
593
+ _margins.left + _domainMargin,
594
+ containerWidth - _margins.right - _domainMargin
595
+ ]);
596
+ return {
597
+ xBarScale,
598
+ yBarScale
599
+ };
600
+ }
601
+ if (_xAxisType === _index1.XAxisTypes.DateAxis) {
602
+ const sDate = (0, _d3array.min)(_dataset, (point)=>{
603
+ return point.x;
604
+ });
605
+ const lDate = (0, _d3array.max)(_dataset, (point)=>{
606
+ return point.x;
607
+ });
608
+ const xBarScale = props.useUTC ? (0, _d3scale.scaleUtc)() : (0, _d3scale.scaleTime)();
609
+ xBarScale.domain(_isRtl ? [
610
+ lDate,
611
+ sDate
612
+ ] : [
613
+ sDate,
614
+ lDate
615
+ ]).range([
616
+ _margins.left + _domainMargin,
617
+ containerWidth - _margins.right - _domainMargin
618
+ ]);
619
+ return {
620
+ xBarScale,
621
+ yBarScale
622
+ };
623
+ }
624
+ const xBarScale = (0, _d3scale.scaleBand)().domain(_xAxisLabels).range(_isRtl ? [
625
+ containerWidth - _margins.right - _domainMargin,
626
+ _margins.left + _domainMargin
627
+ ] : [
628
+ _margins.left + _domainMargin,
629
+ containerWidth - _margins.right - _domainMargin
630
+ ]).paddingInner(_xAxisInnerPadding).paddingOuter(_xAxisOuterPadding);
631
+ return {
632
+ xBarScale,
633
+ yBarScale
634
+ };
635
+ }
636
+ const _isChartEmpty = ()=>{
637
+ return !(props.data && props.data.length > 0 && props.data.some((item)=>item.chartData.length > 0 || item.lineData && item.lineData.length > 0));
638
+ };
639
+ function _updatePosition(newX, newY) {
640
+ const threshold = 1; // Set a threshold for movement
641
+ const { x, y } = clickPosition;
642
+ // Calculate the distance moved
643
+ const distance = Math.sqrt(Math.pow(newX - x, 2) + Math.pow(newY - y, 2));
644
+ // Update the position only if the distance moved is greater than the threshold
645
+ if (distance > threshold) {
646
+ setClickPosition({
647
+ x: newX,
648
+ y: newY
649
+ });
650
+ setPopoverOpen(true);
651
+ }
652
+ }
653
+ function _getDomainMargins(containerWidth) {
654
+ _domainMargin = MIN_DOMAIN_MARGIN;
655
+ /** Total width available to render the bars */ const totalWidth = containerWidth - (_margins.left + MIN_DOMAIN_MARGIN) - (_margins.right + MIN_DOMAIN_MARGIN);
656
+ /** Rate at which the space between the bars changes wrt the bar width */ const barGapRate = _xAxisInnerPadding / (1 - _xAxisInnerPadding);
657
+ if (_xAxisType === _index1.XAxisTypes.StringAxis) {
658
+ if ((0, _index1.isScalePaddingDefined)(props.xAxisOuterPadding, props.xAxisPadding)) {
659
+ // Setting the domain margin for string x-axis to 0 because the xAxisOuterPadding prop is now available
660
+ // to adjust the space before the first bar and after the last bar.
661
+ _domainMargin = 0;
662
+ } else if (props.barWidth !== 'auto') {
663
+ // Update the bar width so that when CartesianChart rerenders,
664
+ // the following calculations don't use the previous bar width.
665
+ _barWidth = (0, _index1.getBarWidth)(props.barWidth, props.maxBarWidth);
666
+ /** Total width required to render the bars. Directly proportional to bar width */ const reqWidth = (_xAxisLabels.length + (_xAxisLabels.length - 1) * barGapRate) * _barWidth;
667
+ if (totalWidth >= reqWidth) {
668
+ // Center align the chart by setting equal left and right margins for domain
669
+ _domainMargin = MIN_DOMAIN_MARGIN + (totalWidth - reqWidth) / 2;
670
+ }
671
+ } else if (props.mode === 'plotly' && _xAxisLabels.length > 1) {
672
+ // Calculate the remaining width after rendering bars at their maximum allowable width
673
+ const bandwidth = totalWidth / (_xAxisLabels.length + (_xAxisLabels.length - 1) * barGapRate);
674
+ const barWidth = (0, _index1.getBarWidth)(props.barWidth, props.maxBarWidth, bandwidth);
675
+ let reqWidth = (_xAxisLabels.length + (_xAxisLabels.length - 1) * barGapRate) * barWidth;
676
+ const margin1 = (totalWidth - reqWidth) / 2;
677
+ // Calculate the remaining width after accounting for the space required to render x-axis labels
678
+ const step = (0, _index1.calculateLongestLabelWidth)(_xAxisLabels) + 20;
679
+ reqWidth = (_xAxisLabels.length - _xAxisInnerPadding) * step;
680
+ const margin2 = (totalWidth - reqWidth) / 2;
681
+ _domainMargin = MIN_DOMAIN_MARGIN + Math.max(0, Math.min(margin1, margin2));
682
+ }
683
+ } else {
684
+ var _props_data;
685
+ const data = ((_props_data = props.data) === null || _props_data === void 0 ? void 0 : _props_data.map((point)=>point.xAxisPoint)) || [];
686
+ _barWidth = (0, _index1.getBarWidth)(props.barWidth, props.maxBarWidth, (0, _index1.calculateAppropriateBarWidth)(data, totalWidth));
687
+ _domainMargin = MIN_DOMAIN_MARGIN + _barWidth / 2;
688
+ }
689
+ return {
690
+ ..._margins,
691
+ left: _margins.left + _domainMargin,
692
+ right: _margins.right + _domainMargin
693
+ };
694
+ }
695
+ function _getChartTitle() {
696
+ const { chartTitle, data } = props;
697
+ const numLines = Object.keys(_lineObject).length;
698
+ return (chartTitle ? `${chartTitle}. ` : '') + `Vertical bar chart with ${(data === null || data === void 0 ? void 0 : data.length) || 0} stacked bars` + (numLines > 0 ? ` and ${numLines} lines` : '') + '. ';
699
+ }
700
+ const classes = (0, _useVerticalStackedBarChartStylesstyles.useVerticalStackedBarChartStyles)(props);
701
+ function _createBar(xBarScale, yBarScale, containerHeight, xElement) {
702
+ const { barCornerRadius = 0, barMinimumHeight = 0 } = props;
703
+ const _isHavingLines = props.data.some((item)=>item.lineData && item.lineData.length > 0);
704
+ const shouldFocusWholeStack = _toFocusWholeStack(_isHavingLines);
705
+ if (_xAxisType === _index1.XAxisTypes.StringAxis) {
706
+ _barWidth = (0, _index1.getBarWidth)(props.barWidth, props.maxBarWidth, xBarScale.bandwidth());
707
+ }
708
+ const bars = _points.map((singleChartData, indexNumber)=>{
709
+ let yPoint = containerHeight - _margins.bottom;
710
+ const xPoint = xBarScale(_xAxisType === _index1.XAxisTypes.NumericAxis ? singleChartData.xAxisPoint : _xAxisType === _index1.XAxisTypes.DateAxis ? singleChartData.xAxisPoint : singleChartData.xAxisPoint);
711
+ const xScaleBandwidthTranslate = _xAxisType !== _index1.XAxisTypes.StringAxis ? -_barWidth / 2 : (xBarScale.bandwidth() - _barWidth) / 2;
712
+ let barTotalValue = 0;
713
+ const barsToDisplay = singleChartData.chartData.filter((point)=>point.data > 0);
714
+ if (!barsToDisplay.length) {
715
+ return undefined;
716
+ }
717
+ const { gapHeight, heightValueScale, adjustedTotalHeight } = _getBarGapAndScale(barsToDisplay, yBarScale);
718
+ if (heightValueScale < 0) {
719
+ return undefined;
720
+ }
721
+ const singleBar = barsToDisplay.map((point, index)=>{
722
+ const startColor = point.color ? point.color : _colors[index];
723
+ const ref = {};
724
+ const shouldHighlight = _isLegendHighlighted(point.legend) || _noLegendHighlighted() ? true : false;
725
+ const rectFocusProps = !shouldFocusWholeStack && {
726
+ 'data-is-focusable': !props.hideTooltip && shouldHighlight,
727
+ 'aria-label': _getAriaLabel(singleChartData, point),
728
+ onMouseOver: (event)=>_onRectHover(singleChartData.xAxisPoint, point, startColor, event),
729
+ onMouseMove: (event)=>_onRectHover(singleChartData.xAxisPoint, point, startColor, event),
730
+ onMouseLeave: _handleMouseOut,
731
+ onFocus: ()=>_onRectFocus(point, singleChartData.xAxisPoint, startColor, ref),
732
+ onBlur: _handleMouseOut,
733
+ onClick: (event)=>_onClick(point, event),
734
+ role: 'img'
735
+ };
736
+ let barHeight = heightValueScale * point.data;
737
+ if (barHeight < Math.max(heightValueScale * adjustedTotalHeight / 100.0, barMinimumHeight)) {
738
+ barHeight = Math.max(heightValueScale * adjustedTotalHeight / 100.0, barMinimumHeight);
739
+ }
740
+ yPoint = yPoint - barHeight - (index ? gapHeight : 0);
741
+ barTotalValue += point.data;
742
+ if (barCornerRadius && barHeight > barCornerRadius && index === barsToDisplay.length - 1) {
743
+ return /*#__PURE__*/ _react.createElement(_react.Fragment, {
744
+ key: index + indexNumber + `${shouldFocusWholeStack}`
745
+ }, /*#__PURE__*/ _react.createElement("path", {
746
+ className: classes.opacityChangeOnHover,
747
+ d: `
748
+ M ${xPoint} ${yPoint + barCornerRadius}
749
+ a ${barCornerRadius} ${barCornerRadius} 0 0 1 ${barCornerRadius} ${-barCornerRadius}
750
+ h ${_barWidth - 2 * barCornerRadius}
751
+ a ${barCornerRadius} ${barCornerRadius} 0 0 1 ${barCornerRadius} ${barCornerRadius}
752
+ v ${barHeight - barCornerRadius}
753
+ h ${-_barWidth}
754
+ z
755
+ `,
756
+ fill: startColor,
757
+ rx: props.roundCorners ? 3 : 0,
758
+ ref: (e)=>ref.refElement = e,
759
+ transform: `translate(${xScaleBandwidthTranslate}, 0)`,
760
+ cursor: props.href ? 'pointer' : 'default',
761
+ ...rectFocusProps
762
+ }));
763
+ }
764
+ if (barHeight < 0) {
765
+ return /*#__PURE__*/ _react.createElement(_react.Fragment, {
766
+ key: index + indexNumber
767
+ }, " ");
768
+ }
769
+ return /*#__PURE__*/ _react.createElement(_react.Fragment, {
770
+ key: index + indexNumber
771
+ }, /*#__PURE__*/ _react.createElement("rect", {
772
+ className: classes.opacityChangeOnHover,
773
+ x: xPoint,
774
+ y: yPoint,
775
+ width: _barWidth,
776
+ height: barHeight,
777
+ fill: startColor,
778
+ opacity: shouldHighlight ? 1 : 0.1,
779
+ cursor: props.href ? 'pointer' : 'default',
780
+ rx: props.roundCorners ? 3 : 0,
781
+ ref: (e)=>ref.refElement = e,
782
+ ...rectFocusProps,
783
+ transform: `translate(${xScaleBandwidthTranslate}, 0)`
784
+ }));
785
+ });
786
+ const groupRef = {};
787
+ const stackFocusProps = shouldFocusWholeStack && {
788
+ 'data-is-focusable': !props.hideTooltip,
789
+ 'aria-label': _getAriaLabel(singleChartData),
790
+ onMouseOver: (event)=>_onStackHover(singleChartData, event),
791
+ onMouseMove: (event)=>_onStackHover(singleChartData, event),
792
+ onMouseLeave: _handleMouseOut,
793
+ onFocus: ()=>_onStackFocus(singleChartData, groupRef),
794
+ onBlur: _handleMouseOut,
795
+ onClick: (event)=>_onClick(singleChartData, event),
796
+ role: 'img'
797
+ };
798
+ let showLabel = false;
799
+ let barLabel = 0;
800
+ if (!props.hideLabels) {
801
+ if (_noLegendHighlighted()) {
802
+ showLabel = true;
803
+ barLabel = barTotalValue;
804
+ } else {
805
+ barsToDisplay.forEach((point)=>{
806
+ if (_isLegendHighlighted(point.legend)) {
807
+ showLabel = true;
808
+ barLabel += point.data;
809
+ }
810
+ });
811
+ }
812
+ }
813
+ return /*#__PURE__*/ _react.createElement("g", {
814
+ key: indexNumber + `${shouldFocusWholeStack}`
815
+ }, /*#__PURE__*/ _react.createElement("g", {
816
+ id: `${indexNumber}-singleBar`,
817
+ ref: (e)=>groupRef.refElement = e,
818
+ ...stackFocusProps,
819
+ tabIndex: !props.hideTooltip ? 0 : undefined
820
+ }, singleBar), !props.hideLabels && _barWidth >= 16 && showLabel && /*#__PURE__*/ _react.createElement("text", {
821
+ x: xPoint + _barWidth / 2,
822
+ y: yPoint - 6,
823
+ textAnchor: "middle",
824
+ className: classes.barLabel,
825
+ "aria-label": `Total: ${barLabel}`,
826
+ role: "img",
827
+ transform: `translate(${xScaleBandwidthTranslate}, 0)`
828
+ }, (0, _index1.formatValueWithSIPrefix)(barLabel)));
829
+ });
830
+ if (!props.showXAxisLablesTooltip) {
831
+ try {
832
+ document.getElementById(_tooltipId) && document.getElementById(_tooltipId).remove();
833
+ // eslint-disable-next-line no-empty
834
+ } catch (e) {}
835
+ }
836
+ if (!props.wrapXAxisLables && props.showXAxisLablesTooltip) {
837
+ const xAxisElement = (0, _d3selection.select)(xElement).call(xBarScale);
838
+ try {
839
+ document.getElementById(_tooltipId) && document.getElementById(_tooltipId).remove();
840
+ // eslint-disable-next-line no-empty
841
+ } catch (e) {}
842
+ const tooltipProps = {
843
+ tooltipCls: classes.tooltip,
844
+ id: _tooltipId,
845
+ xAxis: xAxisElement
846
+ };
847
+ xAxisElement && (0, _index1.tooltipOfXAxislabels)(tooltipProps);
848
+ }
849
+ return bars.filter((bar)=>!!bar);
850
+ }
851
+ if (!_isChartEmpty()) {
852
+ _adjustProps();
853
+ const _isHavingLines = props.data.some((item)=>item.lineData && item.lineData.length > 0);
854
+ const shouldFocusWholeStack = _toFocusWholeStack(_isHavingLines);
855
+ _dataset = _createDataSetLayer();
856
+ const legendBars = _getLegendData(_points, _createLegendsForLine(props.data));
857
+ const calloutProps = {
858
+ color: color,
859
+ legend: calloutLegend,
860
+ XValue: xCalloutValue,
861
+ YValue: yCalloutValue ? yCalloutValue : dataForHoverCard,
862
+ YValueHover: YValueHover,
863
+ hoverXValue: hoverXValue,
864
+ ...props.calloutProps,
865
+ ...(0, _index1.getAccessibleDataObject)(callOutAccessibilityData),
866
+ clickPosition: clickPosition,
867
+ isPopoverOpen: isPopoverOpen,
868
+ isCalloutForStack: props.isCalloutForStack || _isHavingLines && (_noLegendHighlighted() || _getHighlightedLegend().length > 1),
869
+ isCartesian: true,
870
+ customCallout: {
871
+ customizedCallout: _getCustomizedCallout() !== null ? _getCustomizedCallout() : undefined,
872
+ customCalloutProps: props.calloutPropsPerDataPoint ? props.calloutPropsPerDataPoint(dataPointCalloutProps) : undefined
873
+ }
874
+ };
875
+ const tickParams = {
876
+ tickValues: props.tickValues,
877
+ tickFormat: props.tickFormat
878
+ };
879
+ return /*#__PURE__*/ _react.createElement(_index.CartesianChart, {
880
+ ...props,
881
+ chartTitle: _getChartTitle(),
882
+ points: _dataset,
883
+ chartType: _index1.ChartTypes.VerticalStackedBarChart,
884
+ xAxisType: _xAxisType,
885
+ calloutProps: calloutProps,
886
+ tickParams: tickParams,
887
+ legendBars: legendBars,
888
+ datasetForXAxisDomain: _xAxisLabels,
889
+ isCalloutForStack: shouldFocusWholeStack,
890
+ barwidth: _barWidth,
891
+ getmargins: _getMargins,
892
+ getGraphData: _getGraphData,
893
+ getAxisData: _getAxisData,
894
+ onChartMouseLeave: _handleChartMouseLeave,
895
+ getDomainMargins: _getDomainMargins,
896
+ ..._xAxisType === _index1.XAxisTypes.StringAxis && {
897
+ xAxisInnerPadding: _xAxisInnerPadding,
898
+ xAxisOuterPadding: _xAxisOuterPadding
899
+ },
900
+ componentRef: cartesianChartRef,
901
+ /* eslint-disable react/jsx-no-bind */ children: (props)=>{
902
+ return /*#__PURE__*/ _react.createElement(_react.Fragment, null, /*#__PURE__*/ _react.createElement("g", null, _bars), /*#__PURE__*/ _react.createElement("g", null, _isHavingLines && _createLines(props.xScale, props.yScale, props.containerHeight, props.containerWidth, props.yScaleSecondary)));
903
+ }
904
+ });
905
+ }
906
+ return /*#__PURE__*/ _react.createElement("div", {
907
+ id: _emptyChartId,
908
+ role: 'alert',
909
+ style: {
910
+ opacity: '0'
911
+ },
912
+ "aria-label": 'Graph has no data to display'
913
+ });
914
+ };
915
+ VerticalStackedBarChart.displayName = 'VerticalStackedBarChart';