-
Notifications
You must be signed in to change notification settings - Fork 124
Expand file tree
/
Copy pathlib.rs
More file actions
27 lines (26 loc) · 910 Bytes
/
lib.rs
File metadata and controls
27 lines (26 loc) · 910 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use plotly::Plot;
/// Write a plot to HTML files for documentation and display
///
/// This function creates both an inline HTML file (for mdbook inclusion) and
/// a standalone HTML file (for direct viewing). The inline file is prefixed
/// with "inline_" and both files are placed in the "./output" directory.
///
/// # Arguments
///
/// * `plot` - The plot to write to HTML
/// * `name` - The base name for the HTML files (without extension)
///
/// # Returns
///
/// The path to the standalone HTML file
pub fn write_example_to_html(plot: &Plot, name: &str) -> String {
std::fs::create_dir_all("./output").unwrap();
// Write inline HTML
let html = plot.to_inline_html(Some(name));
let path = format!("./output/inline_{name}.html");
std::fs::write(path, html).unwrap();
// Write standalone HTML
let path = format!("./output/{name}.html");
plot.write_html(&path);
path
}