Auto bounds breaks link_axis and link_cursor

未关闭
#75 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
rust

调研方向

首先使用 Cargo.toml 中的依赖运行提供的 Rust 复现代码,然后检查 auto bounds、link_axis 和 link_cursor 的实现。当 auto bounds 处于启用状态时,对于数据宽度不同的 plot,已链接的 plot 轴和光标仍保持对齐,即表示完成。

由索引模型根据 Issue 内容生成。

描述

bug

Describe the bug

While auto bounds is active link_axis and link_cursor does not work if the plot data for the different plots have a different width.

The linking works if the user zoom's in, but when the user double clicks to enable auto bounds the plots are unaligned again.

To Reproduce

Run the following example:

use eframe::egui;
use egui_plot::Line;

fn main() -> eframe::Result {
    let native_options = eframe::NativeOptions::default();

    eframe::run_simple_native("UnalignedPlots", native_options, move |ctx, _frame| {
        egui::CentralPanel::default().show(ctx, |ui| {
            let plot_height = ui.available_height() / 2.0;

            egui_plot::Plot::new("Plot1")
                .height(plot_height)
                .link_axis("plot_axis", [true, false])
                .link_cursor("plot_cursor", [true, false])
                .show(ui, |ui| {
                    ui.line(Line::new(vec![[0.0, 1.0], [10.0, 0.5]]));
                });

            egui_plot::Plot::new("Plot2")
                .height(plot_height)
                .link_axis("plot_axis", [true, false])
                .link_cursor("plot_cursor", [true, false])
                .show(ui, |ui| {
                    ui.line(Line::new(vec![[5.0, 0.5], [7.0, 1.0]]));
                });
        });
    })
}

Cargo.toml:

[package]
name = "unaligned_plots"
version = "0.1.0"
edition = "2021"

[dependencies]
egui = "0.31"
egui_plot = { git = "https://github.com/emilk/egui_plot", branch = "main" }
eframe = { version = "0.31", default-features = false, features = ["x11", "default_fonts", "wgpu"] }

Expected behavior

The x axis for both the cursor and the plot should be linked even while auto bounds is active.

Screenshots

Image

As can be seen in the image both cursor and plot axis are not aligned properly.

主要语言
Rust
星标
494
派生
110
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

emilk/egui_plot 的其他 Issue

查看 emilk/egui_plot 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。