aboutsummaryrefslogtreecommitdiff
path: root/examples/tick_control.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/tick_control.rs')
-rw-r--r--examples/tick_control.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/examples/tick_control.rs b/examples/tick_control.rs
index aca6e71..b34fc88 100644
--- a/examples/tick_control.rs
+++ b/examples/tick_control.rs
@@ -16,9 +16,9 @@ struct CountryData {
data: Vec<DailyData>,
}
+const OUT_FILE_NAME: &'static str = "plotters-doc-data/tick_control.svg";
fn main() -> Result<(), Box<dyn std::error::Error>> {
- let root =
- SVGBackend::new("plotters-doc-data/tick_control.svg", (1024, 768)).into_drawing_area();
+ let root = SVGBackend::new(OUT_FILE_NAME, (1024, 768)).into_drawing_area();
root.fill(&WHITE)?;
let (upper, lower) = root.split_vertically(750);
@@ -77,6 +77,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.border_style(&BLACK)
.draw()?;
+ // To avoid the IO failure being ignored silently, we manually call the present function
+ root.present().expect("Unable to write result to file, please make sure 'plotters-doc-data' dir exists under current dir");
+ println!("Result has been saved to {}", OUT_FILE_NAME);
+
Ok(())
}
#[test]