use malevich::{Frame, Line, Plot, Theme};
use super::html;
use crate::{Element, Plan};
impl<E: Element> Plan<E> {
pub fn to_html(&self, theme: Theme) -> String {
let schedule = html::dump_pre(&self.describe());
let series: Vec<f64> = self
.live_series()
.iter()
.map(|&elements| elements as f64)
.collect();
if series.len() < 2 {
return html::card(theme, "plan", &schedule);
}
let mut frame = Frame::plain(72, 16);
frame.theme = theme;
let plot = Plot::new()
.layer(Line::y(&series[..]).label("live"))
.title("live volume (elements)")
.x_label("scheduled node");
let body = format!(
"{schedule}<div style=\"margin-top:10px\">{}</div>",
plot.to_html(&frame)
);
html::card(theme, "plan", &body)
}
pub fn evcxr_display(&self) {
html::show(&self.to_html(Theme::detect()), &self.describe());
}
}
#[cfg(test)]
#[path = "tests/plan_tests.rs"]
mod tests;