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,28 +8,26 @@ use ratatui::{
|
||||
mod data_graph;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
ratatui::run(|terminal| {
|
||||
loop {
|
||||
terminal.draw(|frame| {
|
||||
let layout = frame.area().layout_vec(&Layout::vertical([
|
||||
Constraint::Percentage(33),
|
||||
Constraint::Percentage(33),
|
||||
Constraint::Percentage(33),
|
||||
]));
|
||||
let middle = layout[1].layout_vec(&Layout::horizontal([
|
||||
Constraint::Percentage(33),
|
||||
Constraint::Percentage(33),
|
||||
Constraint::Percentage(33),
|
||||
]));
|
||||
let widget = Block::new()
|
||||
.border_type(ratatui::widgets::BorderType::Rounded)
|
||||
.borders(Borders::ALL)
|
||||
.title("Mroew");
|
||||
frame.render_widget(widget, middle[1]);
|
||||
})?;
|
||||
if crossterm::event::read().unwrap().is_key_press() {
|
||||
break Ok(());
|
||||
};
|
||||
}
|
||||
ratatui::run(|terminal| loop {
|
||||
terminal.draw(|frame| {
|
||||
let layout = frame.area().layout_vec(&Layout::vertical([
|
||||
Constraint::Percentage(33),
|
||||
Constraint::Percentage(33),
|
||||
Constraint::Percentage(33),
|
||||
]));
|
||||
let middle = layout[1].layout_vec(&Layout::horizontal([
|
||||
Constraint::Percentage(33),
|
||||
Constraint::Percentage(33),
|
||||
Constraint::Percentage(33),
|
||||
]));
|
||||
let widget = Block::new()
|
||||
.border_type(ratatui::widgets::BorderType::Rounded)
|
||||
.borders(Borders::ALL)
|
||||
.title("Mroew");
|
||||
frame.render_widget(widget, middle[1]);
|
||||
})?;
|
||||
if crossterm::event::read().unwrap().is_key_press() {
|
||||
break Ok(());
|
||||
};
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user