`Line::fill` area has a hole where the line is out of view (regression in 0.38)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 85/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- rust
- Lĩnh vực
- data-visualization
Hướng nghiên cứu
Bắt đầu bằng cách đọc egui_plot/src/items/series.rs, đặc biệt là Line::shapes và visible_line_runs; issue liên kết đến cả hai phần liên quan. Chạy bản tái hiện được cung cấp bằng cargo run và so sánh biểu đồ Line::fill với biểu đồ FilledArea. Công việc được xem là hoàn tất khi phần tô vẫn hiển thị bên dưới các đoạn đường nằm ngoài vùng nhìn thấy, kể cả khi cuộn, trong khi các đường không tô vẫn giữ nguyên cách culling hiện tại.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
Line::fill draws no area under a line segment that is out of view, even when the area under it is in view. The fill then has a hole.
This is new in 0.38.0. In 0.37.0 the area is whole. I tried the same plot code with 0.37.0.
You can see the hole in two cases.
- The plot shows only part of the line, for example after you zoom in or pan. The code below does this with
default_y_bounds. - The plot is in a
ScrollAreaand you scroll its top out of view. The area shrinks while you scroll, because each segment that leaves the view takes its area with it.
To Reproduce
- Create a new project with
eframe = "0.37"andegui_plot = "0.38". - Put the code below in
src/main.rs. - Run
cargo run. - Look at the left plot between x = 2 and x = 4.
use eframe::egui::{self, Color32};
use egui_plot::{FilledArea, Line, Plot};
// The line goes up to 9, but the plots show only 0 to 5. The flat top of the line is above them.
const X: [f64; 7] = [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0];
const Y: [f64; 7] = [1.0, 2.0, 8.0, 9.0, 8.0, 2.0, 1.0];
fn plot(id: &'static str) -> Plot<'static> {
Plot::new(id)
.height(240.0)
.default_x_bounds(0.0, 6.0)
.default_y_bounds(0.0, 5.0)
}
fn line() -> Line<'static> {
let points: Vec<[f64; 2]> = X.iter().zip(Y).map(|(x, y)| [*x, y]).collect();
Line::new("y", points).color(Color32::LIGHT_BLUE)
}
pub fn app(ui: &mut egui::Ui) {
egui::CentralPanel::default().show(ui, |ui| {
ui.columns(2, |cols| {
cols[0].label("Line::fill(0.0)");
plot("line_fill").show(&mut cols[0], |p| {
p.line(line().fill(0.0).fill_alpha(0.4));
});
cols[1].label("Same data with FilledArea (what I expect)");
plot("filled_area").show(&mut cols[1], |p| {
let fill = Color32::LIGHT_BLUE.gamma_multiply(0.4);
p.add(FilledArea::new("", &X, &[0.0; 7], &Y).fill_color(fill));
p.line(line());
});
});
});
}
fn main() -> eframe::Result {
eframe::run_ui_native("Line::fill repro", Default::default(), |ui, _frame| app(ui))
}
Expected behavior
The left plot looks like the right plot. The area is filled from the line down to 0, also under the flat top of the line. 0.37.0 draws it this way.
Actual behavior
The left plot has no area between x = 2 and x = 4. The flat top of the line is above the plot, so its segments are dropped, and the area under them with it.
Screenshots
Additional context
Line::shapes builds the fill from the runs that visible_line_runs returns. That function drops every segment whose rect does not touch the clip rect. This is fine for the stroke. It is wrong for the fill, because the area under a dropped segment still reaches into the clip rect.
0.37.0 built the fill from all the points. The culling came with #260, which draws dense lines as bands.
A fix that works for me is to test the segment's rect up to the fill line when fill is set. In visible_line_runs:
- if !clip_rect.intersects(Rect::from_two_pos(previous_position, next_position)) {
+ let mut segment_rect = Rect::from_two_pos(previous_position, next_position);
+ if let Some(y) = fill_y {
+ segment_rect.extend_with_y(y); // the area reaches down to the fill line
+ }
+ if !clip_rect.intersects(segment_rect) {
fill_y is the screen y of the fill line. Line::shapes passes it in, and it is None without fill, so lines without a fill keep the old culling. With this change both plots above look the same, also in a scrolled ScrollArea.
Until then, FilledArea and a plain Line give the right picture, as the right plot shows.
Versions and system
egui_plot0.38.0. The code is the same onmain(d95a746), and the example shows the same hole there.eframeandegui0.37.0- Rust 1.99.1
- macOS 26.6.2, Apple M1 Pro
- The fill is dropped before anything is drawn, so I expect the same on every system. I only tried macOS.
- Ngôn ngữ chính
- Rust
- Star
- 494
- Fork
- 110
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của emilk/egui_plot
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 66/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
Tất cả issue của emilk/egui_plot
Issue tương tự
-
triage: failed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
oxc-project/tsrs#1277 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
autofixer: follow-up triage: bug triage: classified triage: correctness triage: has-reproducer
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
tursodatabase/turso#13221 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Update Wasmtime to 48.0.11 for RUSTSEC-2026-0648Có thể đã có người làm @flyingrobots đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
flyingrobots/edict#457 ·