emilk / emilk/egui_plot

mouseover make the plot to zoom in improperly

Open
#143 6 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
468
Forks
108
Avg merge
15m
Merged PRs (30d)
3

Description

**Describe the bug**
A simple egui_plot app will zoom in improperly when you move your mouse

**To Reproduce**
Steps to reproduce the behavior:
git-checkout the [repo](https://github.com/bombless/egui_plot-mousover-test/tree/86b0c5e8bedf721daa9c4decfc3280f720abb0fb)
or just use the code below
```rust
use eframe::egui;
use egui_plot::{Plot, PlotPoint, Text as PlotText};

fn main() {
let app = App;

let native_options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default()
.with_inner_size([1280.0, 800.0])
.with_title("mouseover test"),
..Default::default()
};

eframe::run_native("test", native_options, Box::new(|_cc| Ok(Box::new(app)))).unwrap();
}

struct App;

impl eframe::App for App {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
let plot = Plot::new("test")
.allow_scroll(true)
.allow_zoom(true)
.allow_boxed_zoom(true)
.allow_drag(true)
.include_x(0.0)
.include_x(0.1);

plot.show(ui, |plot_ui| {
let bounds = plot_ui.plot_bounds();
let val = bounds.min()[0];
plot_ui.text(PlotText::new(
"",
PlotPoint { x: val, y: 0.0 },
val.to_string(),
));
});
});
}
}
```

**Expected behavior**
Moving your mouse won't make the plot zoom in, it should remain the same visual appearance without changing.

**Screenshots**

https://github.com/user-attachments/assets/9862035e-feb4-4e1d-81ee-f56cac4dc22e

**Additional context**
None.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.