rustfmt
This commit is contained in:
parent
1e773605f6
commit
66d9ff301c
@ -1,11 +1,9 @@
|
||||
use crate::chart_manager::ChartManager;
|
||||
use crate::misc::{digits_precision, test_func, Cache};
|
||||
use eframe::{egui, epi};
|
||||
use egui::plot::{Line, Plot, Value, Values};
|
||||
use egui::widgets::plot::{Bar, BarChart};
|
||||
use egui::{
|
||||
plot::{Line, Plot, Value, Values},
|
||||
};
|
||||
use egui::{Color32, plot};
|
||||
use egui::{plot, Color32};
|
||||
|
||||
pub struct MathApp {
|
||||
func_str: String,
|
||||
@ -90,12 +88,9 @@ impl epi::App for MathApp {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
ui.add(egui::Slider::new(num_interval, 1..=usize::MAX).text("Interval"));
|
||||
});
|
||||
|
||||
|
||||
let update_back = chart_manager.do_update_back(func_str.clone(), *min_x, *max_x);
|
||||
let update_front = chart_manager.do_update_front(*num_interval, *resolution);
|
||||
|
||||
@ -122,31 +117,25 @@ impl epi::App for MathApp {
|
||||
|
||||
let bars: Vec<Bar> = match update_front {
|
||||
true => {
|
||||
let bars: Vec<Bar> = rect_data
|
||||
.iter()
|
||||
.map(|(x, y)| Bar::new(*x, *y))
|
||||
.collect();
|
||||
|
||||
bar_cache.set(bars.clone());
|
||||
bars
|
||||
},
|
||||
false => {
|
||||
if bar_cache.is_valid() {
|
||||
bar_cache.get().clone()
|
||||
} else {
|
||||
let bars: Vec<Bar> = rect_data
|
||||
.iter()
|
||||
.map(|(x, y)| Bar::new(*x, *y))
|
||||
.collect();
|
||||
let bars: Vec<Bar> = rect_data.iter().map(|(x, y)| Bar::new(*x, *y)).collect();
|
||||
|
||||
bar_cache.set(bars.clone());
|
||||
bars
|
||||
}
|
||||
},
|
||||
false => {
|
||||
if bar_cache.is_valid() {
|
||||
bar_cache.get().clone()
|
||||
} else {
|
||||
let bars: Vec<Bar> =
|
||||
rect_data.iter().map(|(x, y)| Bar::new(*x, *y)).collect();
|
||||
|
||||
bar_cache.set(bars.clone());
|
||||
bars
|
||||
}
|
||||
}
|
||||
};
|
||||
let bar_chart = BarChart::new(bars).color(Color32::BLUE);
|
||||
|
||||
|
||||
Plot::new("plot")
|
||||
.view_aspect(1.0)
|
||||
.include_y(0)
|
||||
@ -157,7 +146,11 @@ impl epi::App for MathApp {
|
||||
|
||||
let duration = start.elapsed();
|
||||
|
||||
ui.label(format!("Area: {} Took: {:?}", digits_precision(area, 8), duration));
|
||||
ui.label(format!(
|
||||
"Area: {} Took: {:?}",
|
||||
digits_precision(area, 8),
|
||||
duration
|
||||
));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,7 +5,6 @@ mod chart_manager;
|
||||
mod egui_app;
|
||||
mod misc;
|
||||
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
use eframe::{egui, epi};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user