Display the subplot grid in the default browser or Jupyter notebook.
(&self)
| 124 | impl SubplotGrid { |
| 125 | /// Display the subplot grid in the default browser or Jupyter notebook. |
| 126 | pub fn plot(&self) { |
| 127 | use std::env; |
| 128 | |
| 129 | match env::var("EVCXR_IS_RUNTIME") { |
| 130 | Ok(_) => { |
| 131 | let mut plotly_plot = plotly::Plot::new(); |
| 132 | plotly_plot.set_layout(self.layout.clone()); |
| 133 | for trace in self.traces.clone() { |
| 134 | plotly_plot.add_trace(trace); |
| 135 | } |
| 136 | plotly_plot.evcxr_display(); |
| 137 | } |
| 138 | _ => { |
| 139 | let html = self.to_html(); |
| 140 | let dir = std::env::temp_dir(); |
| 141 | let path = dir.join("plotlars_subplot_grid.html"); |
| 142 | std::fs::write(&path, &html).expect("Failed to write HTML file"); |
| 143 | crate::render::open_html_file(&path); |
| 144 | } |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | /// Write the subplot grid to an HTML file. |
| 149 | pub fn write_html(&self, path: impl Into<String>) { |
no test coverage detected