Skip to content

Commit

Permalink
modified: src/egui_plot_stuff/egui_plot_settings.rs
Browse files Browse the repository at this point in the history
	modified:   src/histoer/configs.rs
	modified:   src/histoer/histo1d/histogram1d.rs
	modified:   src/histoer/histogrammer.rs
  • Loading branch information
alconley committed Jan 5, 2025
1 parent e2e74ae commit c41acba
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/egui_plot_stuff/egui_plot_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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(),
}
}
}
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions src/histoer/configs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 2 additions & 0 deletions src/histoer/histo1d/histogram1d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
7 changes: 7 additions & 0 deletions src/histoer/histogrammer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit c41acba

Please sign in to comment.