From 32d0beff220c700fed541769030d0a38c4ce98e6 Mon Sep 17 00:00:00 2001 From: Floyd Wang Date: Thu, 3 Jul 2025 11:28:48 +0800 Subject: [PATCH] plot: Tooltip support multiple dots (#1030) --- crates/ui/src/plot/tooltip.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/ui/src/plot/tooltip.rs b/crates/ui/src/plot/tooltip.rs index f19b6bb6..cc82fe4a 100644 --- a/crates/ui/src/plot/tooltip.rs +++ b/crates/ui/src/plot/tooltip.rs @@ -125,7 +125,7 @@ pub enum TooltipPosition { pub struct TooltipState { pub index: usize, pub cross_line: Point, - pub dot: Point, + pub dots: Vec>, pub position: TooltipPosition, } @@ -133,13 +133,13 @@ impl TooltipState { pub fn new( index: usize, cross_line: Point, - dot: Point, + dots: Vec>, position: TooltipPosition, ) -> Self { Self { index, cross_line, - dot, + dots, position, } } @@ -151,7 +151,7 @@ pub struct Tooltip { position: Option, gap: Pixels, cross_line: Option, - dot: Option, + dots: Option>, } impl Tooltip { @@ -162,7 +162,7 @@ impl Tooltip { position: Default::default(), gap: px(0.), cross_line: None, - dot: None, + dots: None, } } @@ -181,8 +181,8 @@ impl Tooltip { self } - pub fn dot(mut self, dot: Dot) -> Self { - self.dot = Some(dot); + pub fn dots(mut self, dots: impl IntoIterator) -> Self { + self.dots = Some(dots.into_iter().collect()); self } } @@ -224,6 +224,6 @@ impl RenderOnce for Tooltip { } }), ) - .when_some(self.dot, |this, dot| this.child(dot)) + .when_some(self.dots, |this, dots| this.children(dots)) } }