wip
This commit is contained in:
@@ -3,15 +3,27 @@ use ratatui::widgets::Dataset;
|
||||
use data::DataChunk;
|
||||
|
||||
trait Graphable {
|
||||
fn as_dataset(&self) -> Dataset<'_>;
|
||||
fn timeframe(&self, start: u64, end: u64) -> Vec<(f64, f64)>;
|
||||
}
|
||||
|
||||
impl Graphable for SplitData {
|
||||
fn as_dataset(&self) -> Dataset<'_> {
|
||||
unimplemented!("");
|
||||
fn timeframe(&self, start: u64, end: u64) -> Vec<(f64, f64)> {
|
||||
let mut data: Vec<(f64, f64)> = Vec::new();
|
||||
let filtered: Vec<(f64, f64)> = self
|
||||
.chunks
|
||||
.iter()
|
||||
.filter_map(|x| {
|
||||
if x.timestamp >= start && x.timestamp <= end {
|
||||
Some((x.timestamp as f64, x.battery.charge as f64))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
data
|
||||
}
|
||||
}
|
||||
|
||||
struct SplitData {
|
||||
chunks: DataChunk,
|
||||
chunks: Vec<DataChunk>,
|
||||
}
|
||||
|
||||
@@ -8,8 +8,7 @@ use ratatui::{
|
||||
mod data_graph;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
ratatui::run(|terminal| {
|
||||
loop {
|
||||
ratatui::run(|terminal| loop {
|
||||
terminal.draw(|frame| {
|
||||
let layout = frame.area().layout_vec(&Layout::vertical([
|
||||
Constraint::Percentage(33),
|
||||
@@ -30,6 +29,5 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
if crossterm::event::read().unwrap().is_key_press() {
|
||||
break Ok(());
|
||||
};
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user