Skip to content

Commit

Permalink
show timestamp and increment on row id's tooltip
Browse files Browse the repository at this point in the history
[skip ci]
  • Loading branch information
abey79 committed Sep 10, 2024
1 parent 2af5395 commit fd10862
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions crates/viewer/re_space_view_dataframe/src/display_record_batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use re_chunk_store::external::arrow2::{
};
use re_chunk_store::{ColumnDescriptor, ComponentColumnDescriptor, LatestAtQuery, RowId};
use re_dataframe::RecordBatch;
use re_log_types::{EntityPath, TimeInt, Timeline};
use re_log_types::{EntityPath, TimeInt, TimeType, Timeline};
use re_types::external::arrow2::datatypes::IntegerType;
use re_types_core::ComponentName;
use re_ui::UiExt;
Expand Down Expand Up @@ -219,7 +219,7 @@ impl DisplayColumn {
(row_id_times.value(index) as u128) << 64
| (row_id_counters.value(index) as u128),
);
row_id_ui(ui, &row_id);
row_id_ui(ctx, ui, &row_id);
}
Self::Timeline {
timeline,
Expand Down Expand Up @@ -320,13 +320,25 @@ impl DisplayRecordBatch {
}
}

fn row_id_ui(ui: &mut egui::Ui, row_id: &RowId) {
fn row_id_ui(ctx: &ViewerContext<'_>, ui: &mut egui::Ui, row_id: &RowId) {
let s = row_id.to_string();
let split_pos = s.char_indices().nth_back(5);

ui.label(match split_pos {
Some((pos, _)) => &s[pos..],
None => &s,
})
.on_hover_text(s);
.on_hover_ui(|ui| {
let text = format!(
"{}\n\nTimestamp: {}\nIncrement: {}",
s,
(row_id.nanoseconds_since_epoch() as i64)
.try_into()
.map(|t| TimeType::Time.format(TimeInt::from_nanos(t), ctx.app_options.time_zone))
.unwrap_or("error decoding timestamp".to_owned()),
row_id.inc()
);

ui.label(text);
});
}

0 comments on commit fd10862

Please sign in to comment.