Skip to content

Commit

Permalink
Add basic statistics above the plot (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien-berchet authored Jan 31, 2023
1 parent 9f41987 commit 1e69276
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/plot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,31 @@ impl View for PlotWindow {
fn ui(&mut self, ui: &mut egui::Ui, hdf5_group: &hdf::GroupTree) {
ui.separator();

ui.label("Zoom in zoom out using ctrl+mouse.");
let y_data: Vec<f64> = hdf5_group
.handler
.dataset("data")
.unwrap()
.read_raw()
.unwrap();

// Display some basic statistics
let min_value = y_data
.iter()
.min_by(|a, b| a.partial_cmp(b).unwrap())
.unwrap();
let max_value = y_data
.iter()
.max_by(|a, b| a.partial_cmp(b).unwrap())
.unwrap();
ui.label(egui::RichText::new("Statistics:"));
ui.label(egui::RichText::new(format!("min value={:?}", min_value)));
ui.label(egui::RichText::new(format!("max value={:?}", max_value)));

// Plot the data
ui.horizontal(|ui| {
self.trace_plot(ui, hdf5_group).context_menu(|_ui| {});
});
ui.label("Zoom in zoom out using ctrl+mouse.");
}
}

Expand Down

0 comments on commit 1e69276

Please sign in to comment.