Default hover highlight provider that shows the tooltip text with series label, x and y coordinates of the point.
(
ctx: TooltipContext<'_>,
point: &mut HighlightPoint,
)
| 342 | self.with_x_tick_producer(|_, _, _| Vec::new()) |
| 343 | .with_y_tick_producer(|_, _, _| Vec::new()) |
| 344 | } |
| 345 | |
| 346 | /// Default hover highlight provider that shows the tooltip text with |
| 347 | /// series label, x and y coordinates of the point. |
| 348 | pub fn default_hover_highlight_provider( |
| 349 | ctx: TooltipContext<'_>, |
| 350 | point: &mut HighlightPoint, |
| 351 | ) -> Option<String> { |
| 352 | if ctx.series_label.is_empty() { |
| 353 | Some(format!( |
| 354 | "x: {}, y: {}", |
| 355 | point.display_x(), |
| 356 | point.display_y() |
| 357 | )) |
| 358 | } else { |
| 359 | Some(format!( |
| 360 | "{}\nx: {}, y: {}", |
| 361 | ctx.series_label, |
| 362 | point.display_x(), |
| 363 | point.display_y() |
| 364 | )) |
| 365 | } |