From c41acba56e01ea0704dcc82bbb5590355148d637 Mon Sep 17 00:00:00 2001 From: alconley Date: Sun, 5 Jan 2025 14:04:32 -0500 Subject: [PATCH] modified: src/egui_plot_stuff/egui_plot_settings.rs modified: src/histoer/configs.rs modified: src/histoer/histo1d/histogram1d.rs modified: src/histoer/histogrammer.rs --- src/egui_plot_stuff/egui_plot_settings.rs | 8 ++++++++ src/histoer/configs.rs | 4 ++++ src/histoer/histo1d/histogram1d.rs | 2 ++ src/histoer/histogrammer.rs | 7 +++++++ 4 files changed, 21 insertions(+) diff --git a/src/egui_plot_stuff/egui_plot_settings.rs b/src/egui_plot_stuff/egui_plot_settings.rs index c783610..dc1e9c5 100644 --- a/src/egui_plot_stuff/egui_plot_settings.rs +++ b/src/egui_plot_stuff/egui_plot_settings.rs @@ -18,6 +18,8 @@ pub struct EguiPlotSettings { pub allow_double_click_reset: bool, pub limit_scrolling: bool, pub reset_axis: bool, + pub x_label: String, + pub y_label: String, } impl Default for EguiPlotSettings { @@ -41,6 +43,8 @@ impl Default for EguiPlotSettings { allow_double_click_reset: true, limit_scrolling: false, reset_axis: false, + x_label: String::new(), + y_label: String::new(), } } } @@ -68,6 +72,8 @@ impl EguiPlotSettings { &mut self.allow_double_click_reset, "Allow Double Click to Reset", ); + ui.text_edit_singleline(&mut self.x_label); + ui.text_edit_singleline(&mut self.y_label); ui.checkbox(&mut self.limit_scrolling, "Limit Scrolling"); // custom setting if ui.button("Reset Axis").clicked() { @@ -104,6 +110,8 @@ impl EguiPlotSettings { .show_background(self.show_background) .auto_bounds(egui::Vec2b::new(true, true)) .allow_double_click_reset(self.allow_double_click_reset) + .x_axis_label(self.x_label.clone()) + .y_axis_label(self.y_label.clone()) .label_formatter(move |name, value| { let x = if log_x { 10.0f64.powf(value.x) diff --git a/src/histoer/configs.rs b/src/histoer/configs.rs index 81973ac..e2ba8ff 100644 --- a/src/histoer/configs.rs +++ b/src/histoer/configs.rs @@ -358,6 +358,10 @@ impl Configs { } } + pub fn is_empty(&self) -> bool { + self.configs.is_empty() + } + pub fn config_ui(&mut self, ui: &mut egui::Ui) { ui.horizontal(|ui| { ui.label("Histograms"); diff --git a/src/histoer/histo1d/histogram1d.rs b/src/histoer/histo1d/histogram1d.rs index 3cf1de3..8399904 100644 --- a/src/histoer/histo1d/histogram1d.rs +++ b/src/histoer/histo1d/histogram1d.rs @@ -249,6 +249,8 @@ impl Histogram { self.plot_settings.cursor_position = None; } + // self.plot_settings.egui_settings.y_label = format!("Counts/{:.}", self.bin_width); + self.limit_scrolling(plot_ui); } diff --git a/src/histoer/histogrammer.rs b/src/histoer/histogrammer.rs index f292528..44024e6 100644 --- a/src/histoer/histogrammer.rs +++ b/src/histoer/histogrammer.rs @@ -222,6 +222,13 @@ impl Histogrammer { let valid_configs = configs.valid_configs(&mut lf); valid_configs.check_and_add_panes(self); + // if valid configs is empty, return early + if valid_configs.is_empty() { + calculating.store(false, Ordering::SeqCst); + log::error!("No valid configurations found for histograms."); + return; + } + // Select required columns from the LazyFrame let used_columns = valid_configs.get_used_columns(); let selected_columns: Vec<_> = used_columns.iter().map(col).collect();