| 1252 | } |
| 1253 | |
| 1254 | fn get_tooltip_position(&self, tooltip_width: f64, tooltip_height: f64) -> Point<f64> { |
| 1255 | let props = self.props.borrow(); |
| 1256 | let focused_entity_index = self.base.props.borrow().focused_entity_index as usize; |
| 1257 | |
| 1258 | let mut x = self.xlabel_x(focused_entity_index) + props.tooltip_offset; |
| 1259 | let y = f64::max( |
| 1260 | props.xaxis_top - props.yaxis_length, |
| 1261 | props.average_y_values[focused_entity_index] - (tooltip_height / 2.).trunc(), |
| 1262 | ); |
| 1263 | |
| 1264 | let width = self.base.props.borrow().width; |
| 1265 | if x + tooltip_width > width { |
| 1266 | x -= tooltip_width + 2. * props.tooltip_offset; |
| 1267 | x = x.max(props.yaxis_left); |
| 1268 | } |
| 1269 | |
| 1270 | Point::new(x, y) |
| 1271 | } |
| 1272 | } |