summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Forbes <tom@tomforb.es>2020-11-29 16:06:17 +0000
committerTom Forbes <tom@tomforb.es>2020-11-29 16:07:27 +0000
commit78eeb0a69aded1aad89506d0c1d8675f14e0f489 (patch)
tree59c2efa81fc53b2f3090668ea6bee0be879dd3b7
parentecf05a8657667d378f5eeb9ad14fbb6919e76853 (diff)
Add per-dataset boundsper-axis-bounds
-rw-r--r--src/main.rs15
-rw-r--r--src/plot_data.rs2
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<Span> {
// 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<Dataset<'a>> 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])
}
}