Skip to content

Commit

Permalink
fix Plot.show() (#131)
Browse files Browse the repository at this point in the history
* fix Plot.show()

Closes #128

* Update plot.rs

* Update plot.rs

* Update plot.rs
  • Loading branch information
mfreeborn authored Jan 9, 2023
1 parent bec81a3 commit 8903ff0
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions plotly/src/plot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,13 @@ impl Plot {

// Save the rendered plot to the temp file.
let temp_path = temp.to_str().unwrap();
let mut file = File::create(temp_path).unwrap();
file.write_all(rendered.as_bytes())
.expect("failed to write html output");
file.flush().unwrap();

{
let mut file = File::create(temp_path).unwrap();
file.write_all(rendered.as_bytes())
.expect("failed to write html output");
file.flush().unwrap();
}

// Hand off the job of opening the browser to an OS-specific implementation.
Plot::show_with_default_app(temp_path);
Expand All @@ -288,10 +291,13 @@ impl Plot {

// Save the rendered plot to the temp file.
let temp_path = temp.to_str().unwrap();
let mut file = File::create(temp_path).unwrap();
file.write_all(rendered.as_bytes())
.expect("failed to write html output");
file.flush().unwrap();

{
let mut file = File::create(temp_path).unwrap();
file.write_all(rendered.as_bytes())
.expect("failed to write html output");
file.flush().unwrap();
}

// Hand off the job of opening the browser to an OS-specific implementation.
Plot::show_with_default_app(temp_path);
Expand Down Expand Up @@ -467,7 +473,7 @@ impl Plot {
Command::new("cmd")
.arg("/C")
.arg(format!("start {}", temp_path))
.spawn()
.output()
.expect(DEFAULT_HTML_APP_NOT_FOUND);
}
}
Expand Down

0 comments on commit 8903ff0

Please sign in to comment.