diff --git a/src/traits/plot.rs b/src/traits/plot.rs index 0c0e886..650a705 100644 --- a/src/traits/plot.rs +++ b/src/traits/plot.rs @@ -4,16 +4,16 @@ use plotly::{Layout, Plot as Plotly, Trace}; /// A trait representing a generic plot that can be displayed or rendered. pub trait Plot { - #[allow(dead_code)] fn get_layout(&self) -> &Layout; - #[allow(dead_code)] + fn get_traces(&self) -> &Vec>; - #[allow(dead_code)] + fn plot(self) where Self: Sized, { let mut plot = Plotly::new(); + plot.set_layout(self.get_layout().clone()); plot.add_traces(self.get_traces().clone()); @@ -22,4 +22,16 @@ pub trait Plot { _ => plot.show(), } } + + fn write_html(self, path: impl Into) + where + Self: Sized, + { + let mut plot = Plotly::new(); + + plot.set_layout(self.get_layout().clone()); + plot.add_traces(self.get_traces().clone()); + + plot.write_html(path.into()); + } }