Skip to content

Commit

Permalink
fix tests after fixing [BUG] Rotated labels overlap with the chart #551
Browse files Browse the repository at this point in the history
  • Loading branch information
AliMMehr committed Feb 28, 2024
1 parent 313f2a9 commit cea6341
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions plotters/examples/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,13 @@ impl DrawingBackend for TextDrawingBackend {
) -> Result<(), DrawingErrorKind<Self::ErrorType>> {
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,
Expand Down
2 changes: 1 addition & 1 deletion plotters/src/chart/context/cartesian2d/draw_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down

0 comments on commit cea6341

Please sign in to comment.