(
&mut self,
root: &DrawingArea<GpuiBackend, Shift>,
)
| 92 | |
| 93 | impl PlottersChart for CpuUsage { |
| 94 | fn plot( |
| 95 | &mut self, |
| 96 | root: &DrawingArea<GpuiBackend, Shift>, |
| 97 | ) -> Result<(), plotters_gpui::DrawingErrorKind> { |
| 98 | self.try_sample(); |
| 99 | let line = self.get_line(); |
| 100 | let x_min = line.first().map(|(x, _)| *x).unwrap_or(0.0); |
| 101 | let x_max = line.last().map(|(x, _)| *x).unwrap_or(1.0); |
| 102 | let y_min = line.iter().map(|(_, y)| *y).fold(f32::INFINITY, f32::min); |
| 103 | let y_max = line |
| 104 | .iter() |
| 105 | .map(|(_, y)| *y) |
| 106 | .fold(f32::NEG_INFINITY, f32::max); |
| 107 | let mut chart = ChartBuilder::on(root) |
| 108 | .caption("CPU Usage", ("sans-serif", 24).into_font()) |
| 109 | .margin(5) |
| 110 | .x_label_area_size(30) |
| 111 | .y_label_area_size(30) |
| 112 | .build_cartesian_2d(x_min..x_max, y_min..y_max) |
| 113 | .unwrap(); |
| 114 | chart.configure_mesh().draw().unwrap(); |
| 115 | println!("Plot line with {} points", line.len()); |
| 116 | chart.draw_series(LineSeries::new(line, &BLACK)).unwrap(); |
| 117 | |
| 118 | Ok(()) |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | fn main_viewer(cx: &mut App) -> MainViewer { |
nothing calls this directly
no test coverage detected