Skip to content

Commit

Permalink
Fix plot auto-bounds unset by default (#3722)
Browse files Browse the repository at this point in the history
These PR recently cleaned up the code around auto-bounds, but introduced
an involuntary change whereby auto-bounds would not be enabled by
default. All plots would default to being not properly centred as a
result.

- #3587
- #3586

This PR changes the default back to enabled. It also deprecates
`auto_bounds_x()` and `auto_bounds_y()`, which could only enable
auto-bounds (which is not very useful as auto-bounds were, and now are
again, enabled by default). A new `auto_bounds()` API can now be sued to
disable auto-bounds if needed.

Fixes #3712 
Fixes rerun-io/rerun#4503
  • Loading branch information
abey79 authored Dec 19, 2023
1 parent 9253caf commit add1695
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion crates/egui_plot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ impl Plot {
allow_scroll: true,
allow_double_click_reset: true,
allow_boxed_zoom: true,
default_auto_bounds: false.into(),
default_auto_bounds: true.into(),
min_auto_bounds: PlotBounds::NOTHING,
margin_fraction: Vec2::splat(0.05),
boxed_zoom_pointer_button: PointerButton::Secondary,
Expand Down Expand Up @@ -498,14 +498,25 @@ impl Plot {
self
}

/// Set whether the bounds should be automatically set based on data by default.
///
/// This is enabled by default.
#[inline]
pub fn auto_bounds(mut self, auto_bounds: Vec2b) -> Self {
self.default_auto_bounds = auto_bounds;
self
}

/// Expand bounds to fit all items across the x axis, including values given by `include_x`.
#[deprecated = "Use `auto_bounds` instead"]
#[inline]
pub fn auto_bounds_x(mut self) -> Self {
self.default_auto_bounds.x = true;
self
}

/// Expand bounds to fit all items across the y axis, including values given by `include_y`.
#[deprecated = "Use `auto_bounds` instead"]
#[inline]
pub fn auto_bounds_y(mut self) -> Self {
self.default_auto_bounds.y = true;
Expand Down

0 comments on commit add1695

Please sign in to comment.