diff --git a/crates/ui/src/chart/bar_chart.rs b/crates/ui/src/chart/bar_chart.rs index 9618c289..31afbcca 100644 --- a/crates/ui/src/chart/bar_chart.rs +++ b/crates/ui/src/chart/bar_chart.rs @@ -154,8 +154,7 @@ where if let Some(label) = self.label.as_ref() { let label = label.clone(); - bar = - bar.label(move |d, p| Text::new(label(d), p, label_color).align(TextAlign::Center)); + bar = bar.label(move |d, p| vec![Text::new(label(d), p, label_color)]); } bar.paint(&bounds, window, cx); diff --git a/crates/ui/src/plot/shape/bar.rs b/crates/ui/src/plot/shape/bar.rs index 5371fac5..fde45ef2 100644 --- a/crates/ui/src/plot/shape/bar.rs +++ b/crates/ui/src/plot/shape/bar.rs @@ -13,7 +13,7 @@ pub struct Bar { y0: f32, y1: Box Option>, fill: Box Hsla>, - label: Option) -> Text>>, + label: Option) -> Vec>>, } impl Default for Bar { @@ -87,7 +87,7 @@ impl Bar { /// Set the label of the Bar. pub fn label(mut self, label: F) -> Self where - F: Fn(&T, Point) -> Text + 'static, + F: Fn(&T, Point) -> Vec + 'static, { self.label = Some(Box::new(label)); self @@ -121,7 +121,7 @@ impl Bar { graph.push(fill(Bounds::from_corners(p1, p2), color)); if let Some(label) = &self.label { - labels.push(label( + labels.extend(label( v, point( px(x_tick + self.band_width / 2.),