Skip to content

Commit af17d78

Browse files
committed
Fix time series range being affected by invisible plots
1 parent 9ff3b86 commit af17d78

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

crates/viewer/re_view_time_series/src/view_class.rs

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -719,20 +719,32 @@ fn add_series_to_plot(
719719
*scalar_range.end_mut() = f64::NEG_INFINITY;
720720

721721
for series in all_plot_series {
722-
let points = series
723-
.points
724-
.iter()
725-
.map(|p| {
726-
if p.1 < scalar_range.start() {
727-
*scalar_range.start_mut() = p.1;
728-
}
729-
if p.1 > scalar_range.end() {
730-
*scalar_range.end_mut() = p.1;
731-
}
722+
let points = if series.visible {
723+
series
724+
.points
725+
.iter()
726+
.map(|p| {
727+
if p.1 < scalar_range.start() {
728+
*scalar_range.start_mut() = p.1;
729+
}
730+
if p.1 > scalar_range.end() {
731+
*scalar_range.end_mut() = p.1;
732+
}
732733

733-
[(p.0 - time_offset) as _, p.1]
734-
})
735-
.collect::<Vec<_>>();
734+
[(p.0 - time_offset) as _, p.1]
735+
})
736+
.collect::<Vec<_>>()
737+
} else {
738+
// Note we still need to produce a series, so it shows up in the legend.
739+
// As of writing, egui_plot gets confused if this is an empty series, so
740+
// we still add a single point (but don't have it influence the scalar range!)
741+
series
742+
.points
743+
.iter()
744+
.map(|p| [(p.0 - time_offset) as _, p.1])
745+
.take(1)
746+
.collect::<Vec<_>>()
747+
};
736748

737749
let color = series.color;
738750

0 commit comments

Comments
 (0)