sag_components 1.0.1069 → 1.0.1070
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.
|
@@ -93,24 +93,24 @@ const Heatmap = props => {
|
|
|
93
93
|
duration: 0.4
|
|
94
94
|
},
|
|
95
95
|
onMouseEnter: e => {
|
|
96
|
-
var _barRefs$current$inde;
|
|
96
|
+
var _barRefs$current$inde, _barsContainerRef$cur;
|
|
97
97
|
const barRect = (_barRefs$current$inde = barRefs.current[index]) === null || _barRefs$current$inde === void 0 ? void 0 : _barRefs$current$inde.getBoundingClientRect();
|
|
98
|
+
const parentRect = (_barsContainerRef$cur = barsContainerRef.current) === null || _barsContainerRef$cur === void 0 ? void 0 : _barsContainerRef$cur.getBoundingClientRect();
|
|
98
99
|
if (barRect && e.clientX > barRect.x && e.clientX < barRect.x + barRect.width && e.clientY > barRect.y && e.clientY < barRect.y + barRect.height) {
|
|
99
|
-
var _e$nativeEvent, _e$nativeEvent2;
|
|
100
100
|
setTooltip({
|
|
101
101
|
label: `${item.label} - ${Math.round(item.value / totalValue * 100)}%`
|
|
102
102
|
});
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
103
|
+
if (parentRect) {
|
|
104
|
+
let tooltipX = e.clientX + 10; // Default: Position to the right of the cursor
|
|
105
|
+
const tooltipWidth = 150; // Estimate tooltip width (adjust as needed)
|
|
106
|
+
|
|
107
|
+
// If tooltip would overflow, move it to the left of the cursor
|
|
108
|
+
if (tooltipX + tooltipWidth > parentRect.right) {
|
|
109
|
+
tooltipX = e.clientX - tooltipWidth - 10;
|
|
110
|
+
}
|
|
109
111
|
setTooltipPosition({
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
// eslint-disable-next-line no-unsafe-optional-chaining
|
|
113
|
-
y: ((_e$nativeEvent4 = e.nativeEvent) === null || _e$nativeEvent4 === void 0 ? void 0 : _e$nativeEvent4.layerY) + 20
|
|
112
|
+
x: tooltipX,
|
|
113
|
+
y: e.clientY - 30
|
|
114
114
|
});
|
|
115
115
|
}
|
|
116
116
|
}
|
|
@@ -123,21 +123,19 @@ const Heatmap = props => {
|
|
|
123
123
|
}
|
|
124
124
|
},
|
|
125
125
|
onMouseMove: e => {
|
|
126
|
-
var _barRefs$current$inde3;
|
|
126
|
+
var _barRefs$current$inde3, _barsContainerRef$cur2;
|
|
127
127
|
const barRect = (_barRefs$current$inde3 = barRefs.current[index]) === null || _barRefs$current$inde3 === void 0 ? void 0 : _barRefs$current$inde3.getBoundingClientRect();
|
|
128
|
+
const parentRect = (_barsContainerRef$cur2 = barsContainerRef.current) === null || _barsContainerRef$cur2 === void 0 ? void 0 : _barsContainerRef$cur2.getBoundingClientRect();
|
|
128
129
|
if (barRect && e.clientX > barRect.x && e.clientX < barRect.x + barRect.width && e.clientY > barRect.y && e.clientY < barRect.y + barRect.height) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
var _e$nativeEvent7, _e$nativeEvent8;
|
|
130
|
+
if (parentRect) {
|
|
131
|
+
let tooltipX = e.clientX + 10;
|
|
132
|
+
const tooltipWidth = 150;
|
|
133
|
+
if (tooltipX + tooltipWidth > parentRect.right) {
|
|
134
|
+
tooltipX = e.clientX - tooltipWidth - 10;
|
|
135
|
+
}
|
|
136
136
|
setTooltipPosition({
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
// eslint-disable-next-line no-unsafe-optional-chaining
|
|
140
|
-
y: ((_e$nativeEvent8 = e.nativeEvent) === null || _e$nativeEvent8 === void 0 ? void 0 : _e$nativeEvent8.layerY) + 20
|
|
137
|
+
x: tooltipX,
|
|
138
|
+
y: e.clientY - 30
|
|
141
139
|
});
|
|
142
140
|
}
|
|
143
141
|
}
|