1use std::path::Path;
2
3use anyhow::{Result, anyhow};
4use kuva::render::layout::Layout;
5use kuva::render::plots::Plot;
6use kuva::render::render::render_twin_y;
7
8pub const FG_BLUE: &str = "#26a8e0";
11pub const FG_GREEN: &str = "#38b44a";
12pub const FG_PACIFIC: &str = "#1693b9";
13pub const FG_SKY: &str = "#4dcce8";
14pub const FG_TEAL: &str = "#2fae99";
15pub const FG_EMERALD: &str = "#4dcc68";
16pub const FG_FOREST: &str = "#269e2a";
17
18pub const FG_RED: &str = "#e04040";
20
21pub const FG_GRAY: &str = "#b4b4b4";
23
24pub const PLOT_WIDTH: f64 = 800.0;
28pub const PLOT_HEIGHT: f64 = 600.0;
30
31pub fn write_plot_pdf(plots: Vec<Plot>, layout: Layout, path: &Path) -> Result<()> {
41 let pdf_bytes = kuva::render_to_pdf(plots, layout).map_err(|e| anyhow!("{e}"))?;
42 std::fs::write(path, pdf_bytes)?;
43 Ok(())
44}
45
46pub fn write_twin_y_plot_pdf(
54 primary: Vec<Plot>,
55 secondary: Vec<Plot>,
56 layout: Layout,
57 path: &Path,
58) -> Result<()> {
59 let scene = render_twin_y(primary, secondary, layout);
60 let pdf_bytes =
61 kuva::backend::pdf::PdfBackend.render_scene(&scene).map_err(|e| anyhow!("{e}"))?;
62 std::fs::write(path, pdf_bytes)?;
63 Ok(())
64}