Skip to content

Commit cea6341

Browse files
committed
fix tests after fixing [BUG] Rotated labels overlap with the chart #551
1 parent 313f2a9 commit cea6341

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

plotters/examples/console.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,13 @@ impl DrawingBackend for TextDrawingBackend {
131131
) -> Result<(), DrawingErrorKind<Self::ErrorType>> {
132132
let (width, height) = self.estimate_text_size(text, style)?;
133133
let (width, height) = (width as i32, height as i32);
134-
let dx = match style.anchor().h_pos {
134+
let style = style.anchor().unwrap_or_default();
135+
let dx = match style.h_pos {
135136
HPos::Left => 0,
136137
HPos::Right => -width,
137138
HPos::Center => -width / 2,
138139
};
139-
let dy = match style.anchor().v_pos {
140+
let dy = match style.v_pos {
140141
VPos::Top => 0,
141142
VPos::Center => -height / 2,
142143
VPos::Bottom => -height,

plotters/src/chart/context/cartesian2d/draw_impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ impl<'a, DB: DrawingBackend, X: Ranged, Y: Ranged> ChartContext<'a, DB, Cartesia
248248
};
249249

250250
let label_style_with_new_pos = label_style.pos(Pos::new(h_pos, v_pos));
251-
let label_style = match label_style.anchor() {
251+
let label_style = match label_style.pos {
252252
Some(_) => label_style,
253253
None => &label_style_with_new_pos,
254254
};

0 commit comments

Comments
 (0)