wip
This commit is contained in:
@@ -3,15 +3,27 @@ use ratatui::widgets::Dataset;
|
|||||||
use data::DataChunk;
|
use data::DataChunk;
|
||||||
|
|
||||||
trait Graphable {
|
trait Graphable {
|
||||||
fn as_dataset(&self) -> Dataset<'_>;
|
fn timeframe(&self, start: u64, end: u64) -> Vec<(f64, f64)>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Graphable for SplitData {
|
impl Graphable for SplitData {
|
||||||
fn as_dataset(&self) -> Dataset<'_> {
|
fn timeframe(&self, start: u64, end: u64) -> Vec<(f64, f64)> {
|
||||||
unimplemented!("");
|
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 {
|
struct SplitData {
|
||||||
chunks: DataChunk,
|
chunks: Vec<DataChunk>,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,28 +8,26 @@ use ratatui::{
|
|||||||
mod data_graph;
|
mod data_graph;
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
ratatui::run(|terminal| {
|
ratatui::run(|terminal| loop {
|
||||||
loop {
|
terminal.draw(|frame| {
|
||||||
terminal.draw(|frame| {
|
let layout = frame.area().layout_vec(&Layout::vertical([
|
||||||
let layout = frame.area().layout_vec(&Layout::vertical([
|
Constraint::Percentage(33),
|
||||||
Constraint::Percentage(33),
|
Constraint::Percentage(33),
|
||||||
Constraint::Percentage(33),
|
Constraint::Percentage(33),
|
||||||
Constraint::Percentage(33),
|
]));
|
||||||
]));
|
let middle = layout[1].layout_vec(&Layout::horizontal([
|
||||||
let middle = layout[1].layout_vec(&Layout::horizontal([
|
Constraint::Percentage(33),
|
||||||
Constraint::Percentage(33),
|
Constraint::Percentage(33),
|
||||||
Constraint::Percentage(33),
|
Constraint::Percentage(33),
|
||||||
Constraint::Percentage(33),
|
]));
|
||||||
]));
|
let widget = Block::new()
|
||||||
let widget = Block::new()
|
.border_type(ratatui::widgets::BorderType::Rounded)
|
||||||
.border_type(ratatui::widgets::BorderType::Rounded)
|
.borders(Borders::ALL)
|
||||||
.borders(Borders::ALL)
|
.title("Mroew");
|
||||||
.title("Mroew");
|
frame.render_widget(widget, middle[1]);
|
||||||
frame.render_widget(widget, middle[1]);
|
})?;
|
||||||
})?;
|
if crossterm::event::read().unwrap().is_key_press() {
|
||||||
if crossterm::event::read().unwrap().is_key_press() {
|
break Ok(());
|
||||||
break Ok(());
|
};
|
||||||
};
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user