(&self, ui: &mut egui::Ui)
| 26 | } |
| 27 | |
| 28 | pub fn show_plot(&self, ui: &mut egui::Ui) -> Response { |
| 29 | let mut chart = BarChart::new( |
| 30 | "Normal Distribution", |
| 31 | (-395..=395) |
| 32 | .step_by(10) |
| 33 | .map(|x| x as f64 * 0.01) |
| 34 | .map(|x| (x, (-x * x / 2.0).exp() / (2.0 * std::f64::consts::PI).sqrt())) |
| 35 | .map(|(x, f)| Bar::new(x, f * 10.0).width(0.1)) |
| 36 | .collect(), |
| 37 | ) |
| 38 | .color(egui::Color32::LIGHT_BLUE); |
| 39 | |
| 40 | if !self.vertical { |
| 41 | chart = chart.horizontal(); |
| 42 | } |
| 43 | |
| 44 | Plot::new("Normal Distribution Demo") |
| 45 | .legend(Legend::default()) |
| 46 | .clamp_grid(true) |
| 47 | .allow_zoom(egui::Vec2b::new(true, true)) |
| 48 | .allow_drag(egui::Vec2b::new(true, true)) |
| 49 | .allow_scroll(egui::Vec2b::new(true, true)) |
| 50 | .show(ui, |plot_ui| plot_ui.bar_chart(chart)) |
| 51 | .response |
| 52 | } |
| 53 | } |
no test coverage detected