use crate::colors::Color;
use crate::line_style::LineStyle;
pub struct Trace {
pub(crate) x: Vec<f64>,
pub(crate) y: Vec<f64>,
pub(crate) z: Option<Vec<f64>>,
pub(crate) name: Option<String>,
pub(crate) line_color: Option<Color>,
pub(crate) line_width: Option<f64>,
pub(crate) line_style: Option<LineStyle>,
}
impl Trace {
pub fn new_2d(x: impl Into<Vec<f64>>, y: impl Into<Vec<f64>>) -> Trace {
Trace {
x: x.into(),
y: y.into(),
z: None,
name: None,
line_color: None,
line_width: None,
line_style: None,
}
}
pub fn new_3d(x: impl Into<Vec<f64>>, y: impl Into<Vec<f64>>, z: impl Into<Vec<f64>>) -> Trace {
Trace {
x: x.into(),
y: y.into(),
z: Some(z.into()),
name: None,
line_color: None,
line_width: None,
line_style: None,
}
}
pub fn name(mut self, name: impl Into<String>) -> Self {
self.name = Some(name.into());
self
}
pub fn line_color(mut self, line_color: Color) -> Self {
self.line_color = Some(line_color);
self
}
pub fn line_width(mut self, line_width: f64) -> Self {
self.line_width = Some(line_width);
self
}
pub fn line_style(mut self, line_style: LineStyle) -> Self {
self.line_style = Some(line_style);
self
}
}