`Line::fill` area has a hole where the line is out of view (regression in 0.38)
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 85/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- rust
- Domaine
- data-visualization
Piste de recherche
Commencez par lire egui_plot/src/items/series.rs, en particulier Line::shapes et visible_line_runs ; l’issue renvoie aux deux sections pertinentes. Exécutez la reproduction fournie avec cargo run et comparez le graphique Line::fill au graphique FilledArea. Le travail est terminé lorsque le remplissage reste visible sous les segments de ligne hors du champ de vision, y compris lors du défilement, tandis que les lignes non remplies conservent leur découpage actuel.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- Rust
- Étoiles
- 494
- Forks
- 110
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de emilk/egui_plot
-
bug
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100
-
Difficulté 3/5 1-2 jours Accessibilité débutants 66/100
-
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
-
Difficulté 4/5 3-5 jours Accessibilité débutants 45/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 45/100
Toutes les issues de emilk/egui_plot
Issues similaires
-
triage: failed
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
oxc-project/tsrs#1277 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
Les mainteneurs répondent en général sous 1 jour
-
autofixer: follow-up triage: bug triage: classified triage: correctness triage: has-reproducer
Difficulté 2/5 1-3 heures Accessibilité débutants 67/100
tursodatabase/turso#13221 ·
Les mainteneurs répondent en général sous 1 jour
-
Update Wasmtime to 48.0.11 for RUSTSEC-2026-0648Peut-être pris @flyingrobots l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 67/100
flyingrobots/edict#457 ·