INNER CODE UNIT · Rust
new
orf/gping · gping/src/main.rs:172
fn new(data: Vec<PlotData>, buffer: u64, yrange: (Option<f64>, Option<f64>)) -> Self {
App {
data,
display_interval: chrono::Duration::from_std(Duration::from_secs(buffer)).unwrap(),
started: Local::now(),
yrange,
}
}
fn update(&mut self, host_idx: usize, item: Option<Duration>) {
let host = &mut self.data[host_idx];
host.update(item);
}
fn y_axis_bounds(&self) -> [f64; 2] {
// Find the Y axis bounds for our chart.
// This is trickier than the x-axis. We iterate through all our PlotData structs
// and find the min/max of all the values, then add a 10% buffer to each end so