Skip to content

plots ignore the ui layout #237

Description

@melodycatt

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);
            })
        });

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions