emilk / emilk/egui_plot

plots ignore the ui layout

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

Description

using a bottom up layout, plots just go to the top left corner, and overlap each other if there is more than one. i tried getting the height of the response rect from the first plot, then manually adding space, but the second plot goes above the first, off the screen. here is that code:
```
egui::CentralPanel::default().show(ctx, |ui| {
ui.with_layout(egui::Layout::bottom_up(egui::Align::Center), |ui| {
let red = hex("#ff0019");
let accent = hex("#ff7700");
let accent_xl = hex("#ffa600");

ui.style_mut().visuals.override_text_color = Some(red);

let height = Plot::new("a")
.view_aspect(1.75)
.width(ui.available_width() * 0.5)
.allow_scroll(false)
.allow_zoom(false)
.allow_drag(false)
.allow_axis_zoom_drag(false)
.show(ui, |plot_ui| {
plot_ui.line(
Line::new(
"a",
PlotPoints::from_iter(...),
)
.color(accent),
);
})
.response
.rect
.height();

ui.add_space(height);
let height = Plot::new("temp")
.view_aspect(1.75)
.width(ui.available_width() * 0.5)
.allow_scroll(false)
.allow_zoom(false)
.allow_drag(false)
.allow_axis_zoom_drag(false)
.show(ui, |plot_ui| {
plot_ui.line(
Line::new(
"temp",
PlotPoints::from_iter(...),
)
.color(accent),
);
})
.response
.rect
.height();
ui.add_space(height);
})
});
```

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.