From cea6341a1a5ead90b8064bc6aac6b8abbcbf19c5 Mon Sep 17 00:00:00 2001 From: alimm1995 Date: Tue, 27 Feb 2024 22:26:32 -0800 Subject: [PATCH] fix tests after fixing [BUG] Rotated labels overlap with the chart #551 --- plotters/examples/console.rs | 5 +++-- plotters/src/chart/context/cartesian2d/draw_impl.rs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/plotters/examples/console.rs b/plotters/examples/console.rs index 814fb5f2..845e9e60 100644 --- a/plotters/examples/console.rs +++ b/plotters/examples/console.rs @@ -131,12 +131,13 @@ impl DrawingBackend for TextDrawingBackend { ) -> Result<(), DrawingErrorKind> { let (width, height) = self.estimate_text_size(text, style)?; let (width, height) = (width as i32, height as i32); - let dx = match style.anchor().h_pos { + let style = style.anchor().unwrap_or_default(); + let dx = match style.h_pos { HPos::Left => 0, HPos::Right => -width, HPos::Center => -width / 2, }; - let dy = match style.anchor().v_pos { + let dy = match style.v_pos { VPos::Top => 0, VPos::Center => -height / 2, VPos::Bottom => -height, diff --git a/plotters/src/chart/context/cartesian2d/draw_impl.rs b/plotters/src/chart/context/cartesian2d/draw_impl.rs index 22d86a34..e4f09bf1 100644 --- a/plotters/src/chart/context/cartesian2d/draw_impl.rs +++ b/plotters/src/chart/context/cartesian2d/draw_impl.rs @@ -248,7 +248,7 @@ impl<'a, DB: DrawingBackend, X: Ranged, Y: Ranged> ChartContext<'a, DB, Cartesia }; let label_style_with_new_pos = label_style.pos(Pos::new(h_pos, v_pos)); - let label_style = match label_style.anchor() { + let label_style = match label_style.pos { Some(_) => label_style, None => &label_style_with_new_pos, };