@fluentui/react-charts 9.0.2 → 9.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/CHANGELOG.md +48 -7
  2. package/dist/index.d.ts +767 -0
  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 +64 -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/DeclarativeChart/DeclarativeChart.js +112 -65
  25. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  26. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +570 -159
  27. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  28. package/lib/components/DonutChart/Arc/Arc.js +1 -1
  29. package/lib/components/DonutChart/Arc/Arc.js.map +1 -1
  30. package/lib/components/DonutChart/DonutChart.js +1 -1
  31. package/lib/components/DonutChart/DonutChart.js.map +1 -1
  32. package/lib/components/GaugeChart/GaugeChart.js +3 -0
  33. package/lib/components/GaugeChart/GaugeChart.js.map +1 -1
  34. package/lib/components/GaugeChart/GaugeChart.types.js.map +1 -1
  35. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +9 -0
  36. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  37. package/lib/components/HeatMapChart/HeatMapChart.js +588 -0
  38. package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -0
  39. package/lib/components/HeatMapChart/HeatMapChart.types.js +4 -0
  40. package/lib/components/HeatMapChart/HeatMapChart.types.js.map +1 -0
  41. package/lib/components/HeatMapChart/index.js +3 -0
  42. package/lib/components/HeatMapChart/index.js.map +1 -0
  43. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js +46 -0
  44. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -0
  45. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +571 -0
  46. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -0
  47. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js +4 -0
  48. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js.map +1 -0
  49. package/lib/components/HorizontalBarChartWithAxis/index.js +3 -0
  50. package/lib/components/HorizontalBarChartWithAxis/index.js.map +1 -0
  51. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +76 -0
  52. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -0
  53. package/lib/components/Legends/Legends.js +38 -37
  54. package/lib/components/Legends/Legends.js.map +1 -1
  55. package/lib/components/LineChart/LineChart.js +43 -35
  56. package/lib/components/LineChart/LineChart.js.map +1 -1
  57. package/lib/components/SankeyChart/SankeyChart.js +1022 -0
  58. package/lib/components/SankeyChart/SankeyChart.js.map +1 -0
  59. package/lib/components/SankeyChart/SankeyChart.types.js +3 -0
  60. package/lib/components/SankeyChart/SankeyChart.types.js.map +1 -0
  61. package/lib/components/SankeyChart/index.js +3 -0
  62. package/lib/components/SankeyChart/index.js.map +1 -0
  63. package/lib/components/SankeyChart/useSankeyChartStyles.styles.js +109 -0
  64. package/lib/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -0
  65. package/lib/components/ScatterChart/ScatterChart.js +46 -59
  66. package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
  67. package/lib/components/VerticalBarChart/VerticalBarChart.js +165 -88
  68. package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  69. package/lib/components/VerticalBarChart/VerticalBarChart.types.js.map +1 -1
  70. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +904 -0
  71. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -0
  72. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js +1 -0
  73. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -0
  74. package/lib/components/VerticalStackedBarChart/index.js +3 -0
  75. package/lib/components/VerticalStackedBarChart/index.js.map +1 -0
  76. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +73 -0
  77. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -0
  78. package/lib/index.js +5 -0
  79. package/lib/index.js.map +1 -1
  80. package/lib/types/DataPoint.js +1 -3
  81. package/lib/types/DataPoint.js.map +1 -1
  82. package/lib/utilities/SVGTooltipText.js +49 -4
  83. package/lib/utilities/SVGTooltipText.js.map +1 -1
  84. package/lib/utilities/colors.js +20 -0
  85. package/lib/utilities/colors.js.map +1 -1
  86. package/lib/utilities/string.js +32 -0
  87. package/lib/utilities/string.js.map +1 -0
  88. package/lib/utilities/test-data.js +53 -0
  89. package/lib/utilities/test-data.js.map +1 -1
  90. package/lib/utilities/utilities.js +90 -18
  91. package/lib/utilities/utilities.js.map +1 -1
  92. package/lib-commonjs/AreaChart.js +6 -0
  93. package/lib-commonjs/AreaChart.js.map +1 -0
  94. package/lib-commonjs/HeatMapChart.js +6 -0
  95. package/lib-commonjs/HeatMapChart.js.map +1 -0
  96. package/lib-commonjs/HorizontalBarChartWithAxis.js +6 -0
  97. package/lib-commonjs/HorizontalBarChartWithAxis.js.map +1 -0
  98. package/lib-commonjs/SankeyChart.js +6 -0
  99. package/lib-commonjs/SankeyChart.js.map +1 -0
  100. package/lib-commonjs/VerticalStackedBarChart.js +6 -0
  101. package/lib-commonjs/VerticalStackedBarChart.js.map +1 -0
  102. package/lib-commonjs/components/AreaChart/AreaChart.js +781 -0
  103. package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -0
  104. package/lib-commonjs/components/AreaChart/AreaChart.types.js +7 -0
  105. package/lib-commonjs/components/AreaChart/AreaChart.types.js.map +1 -0
  106. package/lib-commonjs/components/AreaChart/index.js +8 -0
  107. package/lib-commonjs/components/AreaChart/index.js.map +1 -0
  108. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js +104 -0
  109. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -0
  110. package/lib-commonjs/components/CommonComponents/CartesianChart.js +29 -14
  111. package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
  112. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
  113. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +120 -73
  114. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  115. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +592 -178
  116. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  117. package/lib-commonjs/components/DonutChart/Arc/Arc.js +1 -1
  118. package/lib-commonjs/components/DonutChart/Arc/Arc.js.map +1 -1
  119. package/lib-commonjs/components/DonutChart/DonutChart.js +1 -1
  120. package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
  121. package/lib-commonjs/components/GaugeChart/GaugeChart.js +3 -0
  122. package/lib-commonjs/components/GaugeChart/GaugeChart.js.map +1 -1
  123. package/lib-commonjs/components/GaugeChart/GaugeChart.types.js.map +1 -1
  124. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +9 -0
  125. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  126. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +599 -0
  127. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -0
  128. package/lib-commonjs/components/HeatMapChart/HeatMapChart.types.js +7 -0
  129. package/lib-commonjs/components/HeatMapChart/HeatMapChart.types.js.map +1 -0
  130. package/lib-commonjs/components/HeatMapChart/index.js +8 -0
  131. package/lib-commonjs/components/HeatMapChart/index.js.map +1 -0
  132. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js +68 -0
  133. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -0
  134. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +580 -0
  135. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -0
  136. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js +7 -0
  137. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js.map +1 -0
  138. package/lib-commonjs/components/HorizontalBarChartWithAxis/index.js +8 -0
  139. package/lib-commonjs/components/HorizontalBarChartWithAxis/index.js.map +1 -0
  140. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +116 -0
  141. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -0
  142. package/lib-commonjs/components/Legends/Legends.js +37 -37
  143. package/lib-commonjs/components/Legends/Legends.js.map +1 -1
  144. package/lib-commonjs/components/LineChart/LineChart.js +41 -33
  145. package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
  146. package/lib-commonjs/components/SankeyChart/SankeyChart.js +1038 -0
  147. package/lib-commonjs/components/SankeyChart/SankeyChart.js.map +1 -0
  148. package/lib-commonjs/components/SankeyChart/SankeyChart.types.js +6 -0
  149. package/lib-commonjs/components/SankeyChart/SankeyChart.types.js.map +1 -0
  150. package/lib-commonjs/components/SankeyChart/index.js +8 -0
  151. package/lib-commonjs/components/SankeyChart/index.js.map +1 -0
  152. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js +179 -0
  153. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -0
  154. package/lib-commonjs/components/ScatterChart/ScatterChart.js +45 -58
  155. package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
  156. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +164 -87
  157. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  158. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.types.js.map +1 -1
  159. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +915 -0
  160. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -0
  161. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js +6 -0
  162. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -0
  163. package/lib-commonjs/components/VerticalStackedBarChart/index.js +8 -0
  164. package/lib-commonjs/components/VerticalStackedBarChart/index.js.map +1 -0
  165. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +120 -0
  166. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -0
  167. package/lib-commonjs/index.js +5 -0
  168. package/lib-commonjs/index.js.map +1 -1
  169. package/lib-commonjs/types/DataPoint.js +1 -3
  170. package/lib-commonjs/types/DataPoint.js.map +1 -1
  171. package/lib-commonjs/utilities/SVGTooltipText.js +49 -4
  172. package/lib-commonjs/utilities/SVGTooltipText.js.map +1 -1
  173. package/lib-commonjs/utilities/colors.js +23 -0
  174. package/lib-commonjs/utilities/colors.js.map +1 -1
  175. package/lib-commonjs/utilities/string.js +29 -0
  176. package/lib-commonjs/utilities/string.js.map +1 -0
  177. package/lib-commonjs/utilities/test-data.js +59 -0
  178. package/lib-commonjs/utilities/test-data.js.map +1 -1
  179. package/lib-commonjs/utilities/utilities.js +94 -17
  180. package/lib-commonjs/utilities/utilities.js.map +1 -1
  181. package/package.json +11 -8
  182. package/lib/components/DeclarativeChart/PlotlySchema.js +0 -7
  183. package/lib/components/DeclarativeChart/PlotlySchema.js.map +0 -1
  184. package/lib-commonjs/components/DeclarativeChart/PlotlySchema.js +0 -10
  185. package/lib-commonjs/components/DeclarativeChart/PlotlySchema.js.map +0 -1
@@ -0,0 +1,775 @@
1
+ import * as React from 'react';
2
+ import { useAreaChartStyles } from './useAreaChartStyles.styles';
3
+ import { max as d3Max, bisector } from 'd3-array';
4
+ import { pointer } from 'd3-selection';
5
+ import { select as d3Select } from 'd3-selection';
6
+ import { tokens } from '@fluentui/react-theme';
7
+ import { area as d3Area, stack as d3Stack, curveMonotoneX as d3CurveBasis, line as d3Line } from 'd3-shape';
8
+ import { CartesianChart } from '../../index';
9
+ import { calloutData, getXAxisType, ChartTypes, XAxisTypes, getTypeOfAxis, tooltipOfXAxislabels, getNextColor, getColorFromToken, formatDate, getSecureProps, areArraysEqual, getCurveFactory, find } from '../../utilities/index';
10
+ import { useId } from '@fluentui/react-utilities';
11
+ import { Legends } from '../Legends/index';
12
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
+ const bisect = bisector((d)=>d.x).left;
14
+ var InterceptVisibility;
15
+ (function(InterceptVisibility) {
16
+ InterceptVisibility["show"] = "visibility";
17
+ InterceptVisibility["hide"] = "hidden";
18
+ })(InterceptVisibility || (InterceptVisibility = {}));
19
+ //by default d3-shape 3.2.0 limits the< path> data point precision to 3 digits(d3/d3-path#10)
20
+ export const AreaChart = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
21
+ var _props_legendProps;
22
+ const _uniqueIdForGraph = useId('areaChart_');
23
+ const _verticalLineId = useId('verticalLine_');
24
+ const _circleId = useId('circle');
25
+ const _rectId = useId('rectangle');
26
+ const _tooltipId = useId('AreaChartTooltipID');
27
+ //enableComputationOptimization is used for optimized code to group data points by x value
28
+ //from O(n^2) to O(n) using a map.
29
+ const _enableComputationOptimization = true;
30
+ const _firstRenderOptimization = true;
31
+ const _emptyChartId = useId('_AreaChart_empty');
32
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
33
+ let _calloutPoints;
34
+ let _createSet;
35
+ let _colors;
36
+ let _opacity;
37
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
38
+ let _data;
39
+ let _chart;
40
+ let _margins;
41
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
42
+ let _xAxisRectScale;
43
+ // determines if the given area chart has multiple stacked bar charts
44
+ let _isMultiStackChart;
45
+ const cartesianChartRef = React.useRef(null);
46
+ const [selectedLegends, setSelectedLegends] = React.useState(((_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.selectedLegends) || []);
47
+ const [activeLegend, setActiveLegend] = React.useState(undefined);
48
+ const [hoverXValue, setHoverXValue] = React.useState('');
49
+ // eslint-disable-next-line @typescript-eslint/no-shadow
50
+ const [YValueHover, setYValueHover] = React.useState([]);
51
+ const [lineXValue, setLineXValue] = React.useState(0);
52
+ const [displayOfLine, setDisplayOfLine] = React.useState("hidden");
53
+ const [isCircleClicked, setIsCircleClicked] = React.useState(false);
54
+ const [nearestCircleToHighlight, setNearestCircleToHighlight] = React.useState(null);
55
+ const [activePoint, setActivePoint] = React.useState('');
56
+ const [dataPointCalloutProps, setDataPointCalloutProps] = React.useState();
57
+ const [stackCalloutProps, setStackCalloutProps] = React.useState();
58
+ const [xAxisCalloutAccessibilityData, setXAxisCalloutAccessibilityData] = React.useState();
59
+ const [clickPosition, setClickPosition] = React.useState({
60
+ x: 0,
61
+ y: 0
62
+ });
63
+ const [isPopoverOpen, setPopoverOpen] = React.useState(false);
64
+ const prevPropsRef = React.useRef(null);
65
+ React.useEffect(()=>{
66
+ if (prevPropsRef.current) {
67
+ var _prevProps_legendProps, _props_legendProps;
68
+ const prevProps = prevPropsRef.current;
69
+ if (!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)) {
70
+ var _props_legendProps1;
71
+ setSelectedLegends(((_props_legendProps1 = props.legendProps) === null || _props_legendProps1 === void 0 ? void 0 : _props_legendProps1.selectedLegends) || []);
72
+ }
73
+ }
74
+ prevPropsRef.current = props;
75
+ }, [
76
+ props
77
+ ]);
78
+ React.useImperativeHandle(props.componentRef, ()=>{
79
+ var _cartesianChartRef_current;
80
+ var _cartesianChartRef_current_chartContainer;
81
+ return {
82
+ 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
83
+ };
84
+ }, []);
85
+ const classes = useAreaChartStyles(props);
86
+ function _getMargins(margins) {
87
+ _margins = margins;
88
+ }
89
+ function _onRectMouseMove(mouseEvent) {
90
+ mouseEvent.persist();
91
+ const { data } = props;
92
+ const { lineChartData } = data;
93
+ _updatePosition(mouseEvent.clientX, mouseEvent.clientY);
94
+ // This will get the value of the X when mouse is on the chart
95
+ // eslint-disable-next-line @nx/workspace-no-restricted-globals
96
+ const xOffset = _xAxisRectScale.invert(pointer(mouseEvent)[0], document.getElementById(_rectId));
97
+ const i = bisect(lineChartData[0].data, xOffset);
98
+ const d0 = lineChartData[0].data[i - 1];
99
+ const d1 = lineChartData[0].data[i];
100
+ let pointToHighlight = null;
101
+ let index = null;
102
+ const axisType = lineChartData[0].data.length > 0 ? getTypeOfAxis(lineChartData[0].data[0].x, true) : null;
103
+ if (d0 === undefined && d1 !== undefined) {
104
+ pointToHighlight = d1.x;
105
+ index = i;
106
+ } else if (d0 !== undefined && d1 === undefined) {
107
+ pointToHighlight = d0.x;
108
+ index = i - 1;
109
+ } else {
110
+ let x0;
111
+ let point0;
112
+ let point1;
113
+ switch(axisType){
114
+ case XAxisTypes.DateAxis:
115
+ x0 = new Date(xOffset).getTime();
116
+ point0 = d0.x.getTime();
117
+ point1 = d1.x.getTime();
118
+ pointToHighlight = Math.abs(x0 - point0) > Math.abs(x0 - point1) ? d1.x : d0.x;
119
+ index = Math.abs(x0 - point0) > Math.abs(x0 - point1) ? i : i - 1;
120
+ break;
121
+ case XAxisTypes.NumericAxis:
122
+ x0 = xOffset;
123
+ point0 = d0.x;
124
+ point1 = d1.x;
125
+ pointToHighlight = Math.abs(x0 - point0) > Math.abs(x0 - point1) ? d1.x : d0.x;
126
+ index = Math.abs(x0 - point0) > Math.abs(x0 - point1) ? i : i - 1;
127
+ break;
128
+ default:
129
+ break;
130
+ }
131
+ }
132
+ // eslint-disable-next-line @typescript-eslint/no-shadow
133
+ const { xAxisCalloutData, xAxisCalloutAccessibilityData } = lineChartData[0].data[index];
134
+ const formattedDate = pointToHighlight instanceof Date ? formatDate(pointToHighlight, props.useUTC) : pointToHighlight;
135
+ const modifiedXVal = pointToHighlight instanceof Date ? pointToHighlight.getTime() : pointToHighlight;
136
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
137
+ const found = find(_calloutPoints, (element)=>{
138
+ return element.x === modifiedXVal;
139
+ });
140
+ // eslint-disable-next-line @typescript-eslint/no-shadow
141
+ const _nearestCircleToHighlight = axisType === XAxisTypes.DateAxis ? pointToHighlight.getTime() : pointToHighlight;
142
+ // if no points need to be called out then don't show vertical line and callout card
143
+ if (found) {
144
+ const filteredValues = _getFilteredLegendValues(found.values);
145
+ setNearestCircleToHighlight(_nearestCircleToHighlight);
146
+ setLineXValue(_xAxisRectScale(pointToHighlight));
147
+ setDisplayOfLine("visibility");
148
+ setIsCircleClicked(false);
149
+ setStackCalloutProps({
150
+ ...found,
151
+ values: filteredValues
152
+ });
153
+ setYValueHover(filteredValues);
154
+ setDataPointCalloutProps({
155
+ ...found,
156
+ values: filteredValues
157
+ });
158
+ setHoverXValue(xAxisCalloutData ? xAxisCalloutData : formattedDate);
159
+ setXAxisCalloutAccessibilityData(xAxisCalloutAccessibilityData);
160
+ setActivePoint('');
161
+ } else {
162
+ setPopoverOpen(false);
163
+ setNearestCircleToHighlight(nearestCircleToHighlight);
164
+ setDisplayOfLine("hidden");
165
+ setIsCircleClicked(false);
166
+ }
167
+ }
168
+ /**
169
+ * just cleaning up the state which we have set in the mouse move event
170
+ */ function _onRectMouseOut() {
171
+ /**/ }
172
+ function _updatePosition(newX, newY) {
173
+ const threshold = 1; // Set a threshold for movement
174
+ const { x, y } = clickPosition;
175
+ // Calculate the distance moved
176
+ const distance = Math.sqrt(Math.pow(newX - x, 2) + Math.pow(newY - y, 2));
177
+ // Update the position only if the distance moved is greater than the threshold
178
+ if (distance > threshold) {
179
+ setClickPosition({
180
+ x: newX,
181
+ y: newY
182
+ });
183
+ setPopoverOpen(true);
184
+ }
185
+ }
186
+ function _handleChartMouseLeave() {
187
+ setPopoverOpen(false);
188
+ setNearestCircleToHighlight(null);
189
+ setLineXValue(0);
190
+ setDisplayOfLine("hidden");
191
+ setIsCircleClicked(false);
192
+ setStackCalloutProps(undefined);
193
+ setDataPointCalloutProps(undefined);
194
+ setHoverXValue(undefined);
195
+ setYValueHover([]);
196
+ }
197
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
198
+ function _getDataPoints(keys, dataSet) {
199
+ var _props_legendProps;
200
+ const renderPoints = [];
201
+ let maxOfYVal = 0;
202
+ if (props.mode === 'tozeroy') {
203
+ keys.forEach((key, index)=>{
204
+ const currentLayer = [];
205
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
206
+ dataSet.forEach((d)=>{
207
+ currentLayer.push({
208
+ values: [
209
+ 0,
210
+ d[key]
211
+ ],
212
+ xVal: d.xVal
213
+ });
214
+ if (d[key] > maxOfYVal) {
215
+ maxOfYVal = d[key];
216
+ }
217
+ });
218
+ renderPoints.push(currentLayer);
219
+ });
220
+ } else {
221
+ const dataValues = d3Stack().keys(keys)(dataSet);
222
+ maxOfYVal = d3Max(dataValues[dataValues.length - 1], (dp)=>dp[1]);
223
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
224
+ dataValues.forEach((layer)=>{
225
+ const currentLayer = [];
226
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
227
+ layer.forEach((d)=>{
228
+ currentLayer.push({
229
+ values: d,
230
+ xVal: d.data.xVal
231
+ });
232
+ });
233
+ renderPoints.push(currentLayer);
234
+ });
235
+ }
236
+ _isMultiStackChart = !!(((_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.selectedLegends) ? (renderPoints === null || renderPoints === void 0 ? void 0 : renderPoints.length) >= 1 : (renderPoints === null || renderPoints === void 0 ? void 0 : renderPoints.length) > 1);
237
+ return {
238
+ renderData: renderPoints,
239
+ maxOfYVal
240
+ };
241
+ }
242
+ function _createDataSet(points) {
243
+ if (props.enablePerfOptimization && _enableComputationOptimization) {
244
+ const allChartPoints = [];
245
+ const dataSet = [];
246
+ const colors = [];
247
+ const opacity = [];
248
+ const calloutPoints = calloutData(points);
249
+ points && points.length && points.forEach((singleChartPoint)=>{
250
+ colors.push(singleChartPoint.color);
251
+ opacity.push(singleChartPoint.opacity || 1);
252
+ allChartPoints.push(...singleChartPoint.data);
253
+ });
254
+ const mapOfXvalToListOfDataPoints = {};
255
+ allChartPoints.forEach((dataPoint)=>{
256
+ const xValue = dataPoint.x instanceof Date ? dataPoint.x.toLocaleString() : dataPoint.x;
257
+ // map of x value to the list of data points which share the same x value .
258
+ if (mapOfXvalToListOfDataPoints[xValue]) {
259
+ mapOfXvalToListOfDataPoints[xValue].push(dataPoint);
260
+ } else {
261
+ mapOfXvalToListOfDataPoints[xValue] = [
262
+ dataPoint
263
+ ];
264
+ }
265
+ });
266
+ Object.keys(mapOfXvalToListOfDataPoints).forEach((key)=>{
267
+ const value = mapOfXvalToListOfDataPoints[key];
268
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
269
+ const singleDataset = {};
270
+ value.forEach((singleDataPoint, index)=>{
271
+ singleDataset.xVal = singleDataPoint.x;
272
+ singleDataset[`chart${index}`] = singleDataPoint.y;
273
+ });
274
+ dataSet.push(singleDataset);
275
+ });
276
+ // get keys from dataset, used to render data
277
+ const keysLength = dataSet && Object.keys(dataSet[0]).length;
278
+ const keys = [];
279
+ for(let i = 0; i < keysLength - 1; i++){
280
+ const keyVal = `chart${i}`;
281
+ keys.push(keyVal);
282
+ }
283
+ // Data used to draw graph
284
+ const data = _getDataPoints(keys, dataSet);
285
+ return {
286
+ colors,
287
+ opacity,
288
+ keys,
289
+ data,
290
+ calloutPoints
291
+ };
292
+ } else {
293
+ const allChartPoints = [];
294
+ const dataSet = [];
295
+ const colors = [];
296
+ const opacity = [];
297
+ const calloutPoints = calloutData(points);
298
+ points && points.length && points.forEach((singleChartPoint)=>{
299
+ colors.push(singleChartPoint.color);
300
+ opacity.push(singleChartPoint.opacity || 1);
301
+ allChartPoints.push(...singleChartPoint.data);
302
+ });
303
+ let tempArr = allChartPoints;
304
+ while(tempArr.length){
305
+ const valToCheck = tempArr[0].x instanceof Date ? tempArr[0].x.toLocaleString() : tempArr[0].x;
306
+ const filteredChartPoints = tempArr.filter((point)=>(point.x instanceof Date ? point.x.toLocaleString() : point.x) === valToCheck);
307
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
308
+ const singleDataset = {};
309
+ filteredChartPoints.forEach((singleDataPoint, index)=>{
310
+ singleDataset.xVal = singleDataPoint.x;
311
+ singleDataset[`chart${index}`] = singleDataPoint.y;
312
+ });
313
+ dataSet.push(singleDataset);
314
+ // removing compared objects from array
315
+ const val = tempArr[0].x instanceof Date ? tempArr[0].x.toLocaleString() : tempArr[0].x;
316
+ tempArr = tempArr.filter((point)=>(point.x instanceof Date ? point.x.toLocaleString() : point.x) !== val);
317
+ }
318
+ // get keys from dataset, used to create stacked data
319
+ const keysLength = dataSet && Object.keys(dataSet[0]).length;
320
+ const keys = [];
321
+ for(let i = 0; i < keysLength - 1; i++){
322
+ const keyVal = `chart${i}`;
323
+ keys.push(keyVal);
324
+ }
325
+ // Data used to draw graph
326
+ const data = _getDataPoints(keys, dataSet);
327
+ return {
328
+ colors,
329
+ opacity,
330
+ keys,
331
+ data,
332
+ calloutPoints
333
+ };
334
+ }
335
+ }
336
+ function _getCustomizedCallout() {
337
+ return props.onRenderCalloutPerStack ? props.onRenderCalloutPerStack(stackCalloutProps) : props.onRenderCalloutPerDataPoint ? props.onRenderCalloutPerDataPoint(dataPointCalloutProps) : null;
338
+ }
339
+ function _getGraphData(// eslint-disable-next-line @typescript-eslint/no-explicit-any
340
+ xAxis, // eslint-disable-next-line @typescript-eslint/no-explicit-any
341
+ yAxis, containerHeight, containerWidth, xElement) {
342
+ _chart = _drawGraph(containerHeight, xAxis, yAxis, xElement);
343
+ }
344
+ function _onLegendHover(legend) {
345
+ setActiveLegend(legend);
346
+ }
347
+ function _onLegendLeave() {
348
+ setActiveLegend(undefined);
349
+ }
350
+ function _getLegendData(points) {
351
+ const data = points;
352
+ const actions = [];
353
+ data.forEach((singleChartData)=>{
354
+ const color = singleChartData.color;
355
+ const checkSimilarLegends = actions.filter((leg)=>leg.title === singleChartData.legend && leg.color === color);
356
+ if (checkSimilarLegends.length > 0) {
357
+ return;
358
+ }
359
+ const legend = {
360
+ title: singleChartData.legend,
361
+ color,
362
+ hoverAction: ()=>{
363
+ _handleChartMouseLeave();
364
+ _onLegendHover(singleChartData.legend);
365
+ },
366
+ onMouseOutAction: ()=>{
367
+ _onLegendLeave();
368
+ }
369
+ };
370
+ actions.push(legend);
371
+ });
372
+ return /*#__PURE__*/ React.createElement(Legends, {
373
+ legends: actions,
374
+ enabledWrapLines: props.enabledLegendsWrapLines,
375
+ ...props.legendProps,
376
+ onChange: _onLegendSelectionChange
377
+ });
378
+ }
379
+ function _onLegendSelectionChange(// eslint-disable-next-line @typescript-eslint/no-shadow
380
+ selectedLegends, event, currentLegend) {
381
+ var _props_legendProps, _props_legendProps1;
382
+ if ((_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.canSelectMultipleLegends) {
383
+ setSelectedLegends(selectedLegends);
384
+ } else {
385
+ setSelectedLegends(selectedLegends.slice(-1));
386
+ }
387
+ if ((_props_legendProps1 = props.legendProps) === null || _props_legendProps1 === void 0 ? void 0 : _props_legendProps1.onChange) {
388
+ props.legendProps.onChange(selectedLegends, event, currentLegend);
389
+ }
390
+ }
391
+ function _onDataPointClick(func) {
392
+ if (func) {
393
+ func();
394
+ }
395
+ setIsCircleClicked(true);
396
+ }
397
+ function _getOpacity(legend) {
398
+ if (!_isMultiStackChart) {
399
+ return 0.7;
400
+ } else {
401
+ const opacity = _legendHighlighted(legend) || _noLegendHighlighted() ? 0.7 : 0.1;
402
+ return opacity;
403
+ }
404
+ }
405
+ function _getLineOpacity(legend) {
406
+ if (!_isMultiStackChart) {
407
+ return 1;
408
+ } else {
409
+ let opacity = 0.3;
410
+ if (isPopoverOpen) {
411
+ opacity = 1;
412
+ }
413
+ if (!_noLegendHighlighted()) {
414
+ opacity = _legendHighlighted(legend) ? 0 : 0.1;
415
+ }
416
+ return opacity;
417
+ }
418
+ }
419
+ function _updateCircleFillColor(xDataPoint, lineColor, circleId) {
420
+ let fillColor = lineColor;
421
+ if (nearestCircleToHighlight === xDataPoint || activePoint === circleId) {
422
+ if (!isCircleClicked) {
423
+ fillColor = tokens.colorNeutralBackground1;
424
+ }
425
+ }
426
+ return fillColor;
427
+ }
428
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
429
+ function _drawGraph(containerHeight, xScale, yScale, xElement) {
430
+ const points = _addDefaultColors(props.data.lineChartData);
431
+ const { pointOptions, pointLineOptions } = props.data;
432
+ const graph = [];
433
+ let lineColor;
434
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
435
+ _data.forEach((singleStackedData, index)=>{
436
+ var _points_index_lineOptions, _points_index_lineOptions1, _points_index_lineOptions2, _points_index_lineOptions3, _points_index_lineOptions4;
437
+ const curveFactory = getCurveFactory((_points_index_lineOptions = points[index].lineOptions) === null || _points_index_lineOptions === void 0 ? void 0 : _points_index_lineOptions.curve, d3CurveBasis);
438
+ const area = d3Area()// eslint-disable-next-line @typescript-eslint/no-explicit-any
439
+ .x((d)=>xScale(d.xVal))// eslint-disable-next-line @typescript-eslint/no-explicit-any
440
+ .y0((d)=>yScale(d.values[0]))// eslint-disable-next-line @typescript-eslint/no-explicit-any
441
+ .y1((d)=>yScale(d.values[1])).curve(curveFactory);
442
+ const line = d3Line()// eslint-disable-next-line @typescript-eslint/no-explicit-any
443
+ .x((d)=>xScale(d.xVal))// eslint-disable-next-line @typescript-eslint/no-explicit-any
444
+ .y((d)=>yScale(d.values[1])).curve(curveFactory);
445
+ const layerOpacity = props.mode === 'tozeroy' ? 0.8 : _opacity[index];
446
+ var _points_index_lineOptions_strokeWidth;
447
+ graph.push(/*#__PURE__*/ React.createElement(React.Fragment, {
448
+ key: `${index}-graph-${_uniqueIdForGraph}`
449
+ }, props.enableGradient && /*#__PURE__*/ React.createElement("defs", null, /*#__PURE__*/ React.createElement("linearGradient", {
450
+ id: `gradient_${index}`,
451
+ x1: "0%",
452
+ x2: "0%",
453
+ y1: "0%",
454
+ y2: "100%"
455
+ }, /*#__PURE__*/ React.createElement("stop", {
456
+ offset: "0",
457
+ stopColor: _colors[index]
458
+ }), /*#__PURE__*/ React.createElement("stop", {
459
+ offset: "100%",
460
+ stopColor: "transparent"
461
+ }))), /*#__PURE__*/ React.createElement("path", {
462
+ id: `${index}-line-${_uniqueIdForGraph}`,
463
+ d: line(singleStackedData),
464
+ fill: 'transparent',
465
+ strokeWidth: (_points_index_lineOptions_strokeWidth = (_points_index_lineOptions1 = points[index].lineOptions) === null || _points_index_lineOptions1 === void 0 ? void 0 : _points_index_lineOptions1.strokeWidth) !== null && _points_index_lineOptions_strokeWidth !== void 0 ? _points_index_lineOptions_strokeWidth : 3,
466
+ stroke: _colors[index],
467
+ opacity: _getLineOpacity(points[index].legend),
468
+ onMouseMove: (event)=>_onRectMouseMove(event),
469
+ onMouseOut: _onRectMouseOut,
470
+ onMouseOver: (event)=>_onRectMouseMove(event),
471
+ strokeDasharray: (_points_index_lineOptions2 = points[index].lineOptions) === null || _points_index_lineOptions2 === void 0 ? void 0 : _points_index_lineOptions2.strokeDasharray,
472
+ strokeDashoffset: (_points_index_lineOptions3 = points[index].lineOptions) === null || _points_index_lineOptions3 === void 0 ? void 0 : _points_index_lineOptions3.strokeDashoffset,
473
+ strokeLinecap: (_points_index_lineOptions4 = points[index].lineOptions) === null || _points_index_lineOptions4 === void 0 ? void 0 : _points_index_lineOptions4.strokeLinecap
474
+ }), singleStackedData.length === 1 ? /*#__PURE__*/ React.createElement("circle", {
475
+ id: `${index}-graph-${_uniqueIdForGraph}`,
476
+ cx: xScale(singleStackedData[0].xVal),
477
+ cy: yScale(singleStackedData[0].values[1]),
478
+ r: 6,
479
+ stroke: _colors[index],
480
+ strokeWidth: 3,
481
+ fill: _colors[index],
482
+ opacity: layerOpacity,
483
+ fillOpacity: _getOpacity(points[index].legend),
484
+ onMouseMove: (event)=>_onRectMouseMove(event),
485
+ onMouseOut: _onRectMouseOut,
486
+ onMouseOver: (event)=>_onRectMouseMove(event)
487
+ }) : /*#__PURE__*/ React.createElement("path", {
488
+ id: `${index}-graph-${_uniqueIdForGraph}`,
489
+ d: area(singleStackedData),
490
+ fill: props.enableGradient ? `url(#gradient_${index})` : _colors[index],
491
+ opacity: layerOpacity,
492
+ fillOpacity: _getOpacity(points[index].legend),
493
+ onMouseMove: (event)=>_onRectMouseMove(event),
494
+ onMouseOut: _onRectMouseOut,
495
+ onMouseOver: (event)=>_onRectMouseMove(event),
496
+ ...props.optimizeLargeData && {
497
+ tabIndex: _legendHighlighted(points[index].legend) || _noLegendHighlighted() ? 0 : undefined,
498
+ role: 'img',
499
+ 'aria-label': `${points[index].legend}, series ${index + 1} of ${points.length} with ${points[index].data.length} data points.`
500
+ }
501
+ })));
502
+ });
503
+ const circleRadius = pointOptions && pointOptions.r ? Number(pointOptions.r) : 8;
504
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
505
+ _data.forEach((singleStackedData, index)=>{
506
+ if (points.length === index) {
507
+ return;
508
+ }
509
+ if (!props.optimizeLargeData || singleStackedData.length === 1) {
510
+ // Render circles for all data points
511
+ graph.push(/*#__PURE__*/ React.createElement("g", {
512
+ key: `${index}-dots-${_uniqueIdForGraph}`,
513
+ clipPath: "url(#clip)",
514
+ role: "region",
515
+ "aria-label": `${points[index].legend}, series ${index + 1} of ${points.length} with ${points[index].data.length} data points.`
516
+ }, singleStackedData.map((singlePoint, pointIndex)=>{
517
+ const circleId = `${_circleId}_${index * _data[0].length + pointIndex}`;
518
+ const xDataPoint = singlePoint.xVal instanceof Date ? singlePoint.xVal.getTime() : singlePoint.xVal;
519
+ lineColor = points[index].color;
520
+ const legend = points[index].legend;
521
+ return /*#__PURE__*/ React.createElement("circle", {
522
+ key: circleId,
523
+ id: circleId,
524
+ tabIndex: _legendHighlighted(points[index].legend) || _noLegendHighlighted() ? 0 : undefined,
525
+ cx: xScale(singlePoint.xVal),
526
+ cy: yScale(singlePoint.values[1]),
527
+ stroke: lineColor,
528
+ strokeWidth: 3,
529
+ fill: _updateCircleFillColor(xDataPoint, lineColor, circleId),
530
+ onMouseOut: _onRectMouseOut,
531
+ onMouseOver: (event)=>_onRectMouseMove(event),
532
+ onClick: ()=>_onDataPointClick(points[index].data[pointIndex].onDataPointClick),
533
+ onFocus: ()=>_handleFocus(index, pointIndex, circleId),
534
+ onBlur: _handleBlur,
535
+ ...getSecureProps(pointOptions),
536
+ r: _getCircleRadius(xDataPoint, circleRadius, circleId, legend),
537
+ role: "img",
538
+ "aria-label": _getAriaLabel(index, pointIndex)
539
+ });
540
+ })));
541
+ } else {
542
+ // Render circles for data points close to the mouse pointer only
543
+ singleStackedData.forEach((singlePoint, pointIndex)=>{
544
+ const xDataPoint = singlePoint.xVal instanceof Date ? singlePoint.xVal.getTime() : singlePoint.xVal;
545
+ if (nearestCircleToHighlight === xDataPoint) {
546
+ const circleId = `${_circleId}_${index * _data[0].length + pointIndex}`;
547
+ lineColor = points[index].color;
548
+ const legend = points[index].legend;
549
+ graph.push(/*#__PURE__*/ React.createElement("circle", {
550
+ key: circleId,
551
+ id: circleId,
552
+ cx: xScale(singlePoint.xVal),
553
+ cy: yScale(singlePoint.values[1]),
554
+ stroke: lineColor,
555
+ strokeWidth: 3,
556
+ fill: _updateCircleFillColor(xDataPoint, lineColor, circleId),
557
+ onMouseOut: _onRectMouseOut,
558
+ onMouseOver: (event)=>_onRectMouseMove(event),
559
+ onClick: ()=>_onDataPointClick(points[index].data[pointIndex].onDataPointClick),
560
+ ...getSecureProps(pointOptions),
561
+ r: _getCircleRadius(xDataPoint, circleRadius, circleId, legend)
562
+ }));
563
+ }
564
+ });
565
+ }
566
+ });
567
+ graph.push(/*#__PURE__*/ React.createElement("line", {
568
+ id: _verticalLineId,
569
+ key: _verticalLineId,
570
+ x1: lineXValue,
571
+ y1: 0,
572
+ x2: lineXValue,
573
+ y2: containerHeight,
574
+ strokeWidth: 1,
575
+ strokeDasharray: 5.5,
576
+ stroke: lineColor,
577
+ opacity: 0.5,
578
+ visibility: displayOfLine,
579
+ ...getSecureProps(pointLineOptions)
580
+ }));
581
+ // Removing un wanted tooltip div from DOM, when prop not provided.
582
+ if (!props.showXAxisLablesTooltip) {
583
+ try {
584
+ // eslint-disable-next-line @nx/workspace-no-restricted-globals
585
+ document.getElementById(_tooltipId) && document.getElementById(_tooltipId).remove();
586
+ // eslint-disable-next-line no-empty
587
+ } catch (e) {}
588
+ }
589
+ // Used to display tooltip at x axis labels.
590
+ if (!props.wrapXAxisLables && props.showXAxisLablesTooltip) {
591
+ const xAxisElement = d3Select(xElement).call(xScale);
592
+ try {
593
+ // eslint-disable-next-line @nx/workspace-no-restricted-globals
594
+ document.getElementById(_tooltipId) && document.getElementById(_tooltipId).remove();
595
+ // eslint-disable-next-line no-empty
596
+ } catch (e) {}
597
+ const tooltipProps = {
598
+ tooltipCls: classes.tooltip,
599
+ id: _tooltipId,
600
+ xAxis: xAxisElement
601
+ };
602
+ xAxisElement && tooltipOfXAxislabels(tooltipProps);
603
+ }
604
+ return graph;
605
+ }
606
+ function _getCircleRadius(xDataPoint, circleRadius, circleId, legend) {
607
+ // Show the circle if no legends are selected or if the point's legend is in the selected legends
608
+ if (!_noLegendHighlighted() && !_legendHighlighted(legend)) {
609
+ return 0;
610
+ }
611
+ if (isCircleClicked && nearestCircleToHighlight === xDataPoint) {
612
+ return 1;
613
+ } else if (nearestCircleToHighlight === xDataPoint || activePoint === circleId) {
614
+ return circleRadius;
615
+ } else {
616
+ return 0;
617
+ }
618
+ }
619
+ /**
620
+ * This function checks if the given legend is highlighted or not.
621
+ * A legend can be highlighted in 2 ways:
622
+ * 1. selection: if the user clicks on it
623
+ * 2. hovering: if there is no selected legend and the user hovers over it
624
+ */ function _legendHighlighted(legend) {
625
+ return _getHighlightedLegend().includes(legend);
626
+ }
627
+ /**
628
+ * This function checks if none of the legends is selected or hovered.
629
+ */ function _noLegendHighlighted() {
630
+ return _getHighlightedLegend().length === 0;
631
+ }
632
+ function _getHighlightedLegend() {
633
+ return selectedLegends.length > 0 ? selectedLegends : activeLegend ? [
634
+ activeLegend
635
+ ] : [];
636
+ }
637
+ function _addDefaultColors(lineChartData) {
638
+ return lineChartData ? lineChartData.map((item, index)=>{
639
+ let color;
640
+ // isInverted property is applicable to v8 themes only
641
+ if (typeof item.color === 'undefined') {
642
+ color = getNextColor(index, 0);
643
+ } else {
644
+ color = getColorFromToken(item.color);
645
+ }
646
+ return {
647
+ ...item,
648
+ color
649
+ };
650
+ }) : [];
651
+ }
652
+ function _handleFocus(lineIndex, pointIndex, circleId) {
653
+ const { x, y, xAxisCalloutData } = props.data.lineChartData[lineIndex].data[pointIndex];
654
+ const formattedDate = x instanceof Date ? formatDate(x, props.useUTC) : x;
655
+ const modifiedXVal = x instanceof Date ? x.getTime() : x;
656
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
657
+ const found = _calloutPoints.find((e)=>e.x === modifiedXVal);
658
+ // Show details in the callout for the focused point only
659
+ found.values = found.values.filter((e)=>e.y === y);
660
+ const filteredValues = _getFilteredLegendValues(found.values);
661
+ setPopoverOpen(true);
662
+ setHoverXValue(xAxisCalloutData ? xAxisCalloutData : formattedDate);
663
+ setYValueHover(filteredValues);
664
+ setStackCalloutProps({
665
+ ...found,
666
+ values: filteredValues
667
+ });
668
+ setDataPointCalloutProps({
669
+ ...found,
670
+ values: filteredValues
671
+ });
672
+ setActivePoint(circleId);
673
+ }
674
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
675
+ function _getFilteredLegendValues(values) {
676
+ return !_noLegendHighlighted() ? values.filter((value)=>_legendHighlighted(value.legend)) : values;
677
+ }
678
+ function _handleBlur() {
679
+ setPopoverOpen(false);
680
+ setHoverXValue(undefined);
681
+ setYValueHover([]);
682
+ setStackCalloutProps(undefined);
683
+ setDataPointCalloutProps(undefined);
684
+ setActivePoint('');
685
+ }
686
+ function _getAriaLabel(lineIndex, pointIndex) {
687
+ var _point_callOutAccessibilityData;
688
+ const line = props.data.lineChartData[lineIndex];
689
+ const point = line.data[pointIndex];
690
+ const formattedDate = point.x instanceof Date ? formatDate(point.x, props.useUTC) : point.x;
691
+ const xValue = point.xAxisCalloutData || formattedDate;
692
+ const legend = line.legend;
693
+ const yValue = point.yAxisCalloutData || point.y;
694
+ return ((_point_callOutAccessibilityData = point.callOutAccessibilityData) === null || _point_callOutAccessibilityData === void 0 ? void 0 : _point_callOutAccessibilityData.ariaLabel) || `${xValue}. ${legend}, ${yValue}.`;
695
+ }
696
+ function _isChartEmpty() {
697
+ return !(props.data && props.data.lineChartData && props.data.lineChartData.length > 0 && // eslint-disable-next-line @typescript-eslint/no-explicit-any
698
+ props.data.lineChartData.filter((item)=>item.data.length === 0).length === 0);
699
+ }
700
+ function _getChartTitle() {
701
+ const { chartTitle, lineChartData } = props.data;
702
+ return (chartTitle ? `${chartTitle}. ` : '') + `Area chart with ${(lineChartData === null || lineChartData === void 0 ? void 0 : lineChartData.length) || 0} data series. `;
703
+ }
704
+ if (!_isChartEmpty()) {
705
+ const { lineChartData } = props.data;
706
+ const points = _addDefaultColors(lineChartData);
707
+ _createSet = _createDataSet;
708
+ const { colors, opacity, data, calloutPoints } = _createSet(points);
709
+ _calloutPoints = calloutPoints;
710
+ const isXAxisDateType = getXAxisType(points);
711
+ _colors = colors;
712
+ _opacity = opacity;
713
+ _data = data.renderData;
714
+ const legends = _getLegendData(points);
715
+ const tickParams = {
716
+ tickValues: props.tickValues,
717
+ tickFormat: props.tickFormat
718
+ };
719
+ const calloutProps = {
720
+ YValueHover: YValueHover,
721
+ hoverXValue: hoverXValue,
722
+ xAxisCalloutAccessibilityData,
723
+ ...props.calloutProps,
724
+ clickPosition,
725
+ isPopoverOpen,
726
+ isCartesian: true,
727
+ customCallout: {
728
+ customizedCallout: _getCustomizedCallout() !== null ? _getCustomizedCallout() : undefined,
729
+ customCalloutProps: props.calloutPropsPerDataPoint ? props.calloutPropsPerDataPoint(dataPointCalloutProps) : undefined
730
+ },
731
+ isCalloutForStack: true
732
+ };
733
+ return /*#__PURE__*/ React.createElement(CartesianChart, {
734
+ ...props,
735
+ chartTitle: _getChartTitle(),
736
+ points: points,
737
+ chartType: ChartTypes.AreaChart,
738
+ calloutProps: calloutProps,
739
+ legendBars: legends,
740
+ xAxisType: isXAxisDateType ? XAxisTypes.DateAxis : XAxisTypes.NumericAxis,
741
+ tickParams: tickParams,
742
+ maxOfYVal: data.maxOfYVal,
743
+ getGraphData: _getGraphData,
744
+ getmargins: _getMargins,
745
+ onChartMouseLeave: _handleChartMouseLeave,
746
+ enableFirstRenderOptimization: props.enablePerfOptimization && _firstRenderOptimization,
747
+ componentRef: cartesianChartRef,
748
+ /* eslint-disable react/jsx-no-bind */ // eslint-disable-next-line react/no-children-prop, @typescript-eslint/no-shadow
749
+ children: (props)=>{
750
+ _xAxisRectScale = props.xScale;
751
+ const ticks = _xAxisRectScale.ticks();
752
+ const width1 = _xAxisRectScale(ticks[ticks.length - 1]);
753
+ const rectHeight = props.containerHeight - _margins.top;
754
+ return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement("g", null, /*#__PURE__*/ React.createElement("rect", {
755
+ id: _rectId,
756
+ width: width1,
757
+ height: rectHeight,
758
+ fill: 'transparent',
759
+ onMouseMove: (event)=>_onRectMouseMove(event),
760
+ onMouseOut: _onRectMouseOut,
761
+ onMouseOver: (event)=>_onRectMouseMove(event)
762
+ })), /*#__PURE__*/ React.createElement("g", null, _chart));
763
+ }
764
+ });
765
+ }
766
+ return /*#__PURE__*/ React.createElement("div", {
767
+ id: _emptyChartId,
768
+ role: 'alert',
769
+ style: {
770
+ opacity: '0'
771
+ },
772
+ "aria-label": 'Graph has no data to display'
773
+ });
774
+ });
775
+ AreaChart.displayName = 'AreaChart';