(&mut self, ui: &mut egui::Ui)
| 158 | } |
| 159 | |
| 160 | pub fn show_plot(&mut self, ui: &mut egui::Ui) -> Response { |
| 161 | if self.animate { |
| 162 | ui.request_repaint(); |
| 163 | self.time += ui.input(|i| i.unstable_dt).at_most(1.0 / 30.0) as f64; |
| 164 | } |
| 165 | let mut plot = Plot::new("lines_demo") |
| 166 | .legend(Legend::default().title("Lines")) |
| 167 | .show_axes(self.show_axes) |
| 168 | .show_grid(self.show_grid) |
| 169 | .show_crosshair(self.show_crosshair) |
| 170 | .invert_x(self.invert_x) |
| 171 | .invert_y(self.invert_y); |
| 172 | if self.square { |
| 173 | plot = plot.view_aspect(1.0); |
| 174 | } |
| 175 | if self.proportional { |
| 176 | plot = plot.data_aspect(1.0); |
| 177 | } |
| 178 | if self.coordinates { |
| 179 | plot = plot.coordinates_formatter(Corner::LeftBottom, CoordinatesFormatter::default()); |
| 180 | } |
| 181 | if self.show_labels { |
| 182 | plot = plot.label_formatter(default_label_formatter); |
| 183 | } |
| 184 | plot.show(ui, |plot_ui| { |
| 185 | plot_ui.line(self.circle()); |
| 186 | plot_ui.line(self.sin()); |
| 187 | plot_ui.line(self.thingy()); |
| 188 | }) |
| 189 | .response |
| 190 | } |
| 191 | } |
no test coverage detected