Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ugly UI for some arrow data #5235

Merged
merged 5 commits into from
Feb 20, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Don't show huge datatypes
  • Loading branch information
emilk committed Feb 20, 2024
commit 5bed245aadaac741c1fbb2fb920b6562489b3483
17 changes: 12 additions & 5 deletions crates/re_data_ui/src/component_ui_registry.rs
Original file line number Diff line number Diff line change
@@ -109,11 +109,18 @@ fn arrow_ui(ui: &mut egui::Ui, verbosity: UiVerbosity, array: &dyn arrow2::array
}

// Fallback:
ui.label(format!(
"{} of {:?}",
re_format::format_bytes(num_bytes as _),
array.data_type()
));
let bytes = re_format::format_bytes(num_bytes as _);

// TODO(emilk): pretty-print data type
let data_type_formatted = format!("{:?}", array.data_type());

if data_type_formatted.len() < 20 {
// e.g. "4.2 KiB of Float32"
text_ui(ui, verbosity, &format!("{bytes} of {data_type_formatted}"));
} else {
// Huge datatype, probably a union horror show
ui.label(format!("{bytes} of data"));
}
}

fn text_ui(ui: &mut egui::Ui, verbosity: UiVerbosity, string: &str) {