From 78eeb0a69aded1aad89506d0c1d8675f14e0f489 Mon Sep 17 00:00:00 2001 From: Tom Forbes Date: Sun, 29 Nov 2020 16:06:17 +0000 Subject: Add per-dataset bounds --- src/main.rs | 15 +-------------- src/plot_data.rs | 2 +- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7d59d05..445daf4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -90,15 +90,6 @@ impl App { [min - min_10_percent, max + max_10_percent] } - fn x_axis_bounds(&self) -> [f64; 2] { - let window_min = self.data.iter().map(|d| d.window_min); - let window_max = self.data.iter().map(|d| d.window_max); - [ - window_min.fold(f64::INFINITY, |a, b| a.min(b)), - window_max.fold(0f64, |a, b| a.max(b)), - ] - } - fn y_axis_labels(&self, bounds: [f64; 2]) -> Vec { // Create 7 labels for our y axis, based on the y-axis bounds we computed above. let min = bounds[0]; @@ -325,11 +316,7 @@ fn main() -> Result<()> { let chart = Chart::new(datasets) .block(Block::default().borders(Borders::NONE)) - .x_axis( - Axis::default() - .style(Style::default().fg(Color::Gray)) - .bounds(app.x_axis_bounds()), - ) + .x_axis(Axis::default().style(Style::default().fg(Color::Gray))) .y_axis( Axis::default() .style(Style::default().fg(Color::Gray)) diff --git a/src/plot_data.rs b/src/plot_data.rs index 845a59b..917c301 100644 --- a/src/plot_data.rs +++ b/src/plot_data.rs @@ -80,6 +80,6 @@ impl<'a> Into> for &'a PlotData { .style(self.style) .graph_type(GraphType::Line) .data(slice) - // .x_axis_bounds([self.window_min, self.window_max]) + .x_axis_bounds([self.window_min, self.window_max]) } } -- cgit v1.2.3