`Line::fill` area has a hole where the line is out of view (regression in 0.38)
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 85/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- rust
- Área
- data-visualization
Línea de trabajo
Empieza leyendo egui_plot/src/items/series.rs, especialmente Line::shapes y visible_line_runs; el issue enlaza a ambas secciones relevantes. Ejecuta la reproducción proporcionada con cargo run y compara el gráfico Line::fill con el gráfico FilledArea. Se considerará terminado cuando el relleno siga siendo visible bajo los segmentos de línea que quedan fuera de la vista, incluso al desplazarse, mientras que las líneas sin relleno mantienen su recorte actual.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Rust
- Estrellas
- 494
- Forks
- 110
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de emilk/egui_plot
-
bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 66/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 45/100
Todos los issues de emilk/egui_plot
Issues similares
-
triage: failed
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
oxc-project/tsrs#1277 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
autofixer: follow-up triage: bug triage: classified triage: correctness triage: has-reproducer
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
tursodatabase/turso#13221 ·
Los mantenedores suelen responder en 1 día
-
Update Wasmtime to 48.0.11 for RUSTSEC-2026-0648Posiblemente ocupada @flyingrobots la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
flyingrobots/edict#457 ·