use malevich::{Frame, Line, Plot, Theme};
use super::html;
use crate::{Differentiable, Plan};
impl<Data: Differentiable> Plan<Data> {
pub fn to_html(&self, theme: Theme) -> String {
let schedule = format!(
"<pre style=\"margin:0;white-space:pre;overflow-x:auto\">{}</pre>",
html::escape(&self.describe())
);
let series = self.live_series();
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;