Skip to content

Commit 9d77794

Browse files
authored
Fix timeseries time view min fallback (#11992)
### Related * Fixes some stuff I missed in #11938 ### What Fixes the min fallback for the time axis min, which had issues if you changed the min visible time range.
1 parent 53e80a0 commit 9d77794

File tree

3 files changed

+14
-21
lines changed

3 files changed

+14
-21
lines changed

crates/viewer/re_view_time_series/src/view_class.rs

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -478,10 +478,15 @@ impl ViewClass for TimeSeriesView {
478478
};
479479
state.time_offset = time_offset;
480480

481-
// Get the maximum time/X value for the entire plot
482-
let max_time = all_plot_series
481+
// Get the min and max time/X value for the visible plot.
482+
let min_view_time = all_plot_series
483483
.iter()
484-
.map(|line| line.points.last().map(|(t, _)| *t).unwrap_or(line.min_time))
484+
.filter_map(|line| line.points.first().map(|(t, _)| *t))
485+
.min()
486+
.unwrap_or(0);
487+
let max_view_time = all_plot_series
488+
.iter()
489+
.filter_map(|line| line.points.last().map(|(t, _)| *t))
485490
.max()
486491
.unwrap_or(0);
487492

@@ -498,8 +503,8 @@ impl ViewClass for TimeSeriesView {
498503
.unwrap_or_default();
499504

500505
state.max_time_view_range = AbsoluteTimeRange::new(
501-
TimeInt::saturated_temporal_i64(min_time),
502-
TimeInt::saturated_temporal_i64(max_time),
506+
TimeInt::saturated_temporal_i64(min_view_time),
507+
TimeInt::saturated_temporal_i64(max_view_time),
503508
);
504509

505510
let blueprint_db = ctx.blueprint_db();
@@ -620,18 +625,6 @@ impl ViewClass for TimeSeriesView {
620625
.map(|line| line.aggregator)
621626
.unwrap_or_default();
622627

623-
// …then use that as an offset to avoid nasty precision issues with
624-
// large times (nanos since epoch does not fit into a f64).
625-
let time_offset = match timeline.typ() {
626-
TimeType::Sequence => min_time,
627-
TimeType::TimestampNs | TimeType::DurationNs => {
628-
// In order to make the tick-marks on the time axis fall on whole days, hours, minutes etc,
629-
// we need to round to a whole day:
630-
round_nanos_to_start_of_day(min_time)
631-
}
632-
};
633-
state.time_offset = time_offset;
634-
635628
// TODO(#5075): Boxed-zoom should be fixed to accommodate the locked range.
636629
let timestamp_format = ctx.app_options().timestamp_format;
637630

Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading

0 commit comments

Comments
 (0)