use crate::mark::Mark;
use crate::visual::color::SingleColor;
#[derive(Debug, Clone)]
pub struct MarkBoxplot {
pub(crate) color: SingleColor,
pub(crate) opacity: f64,
pub(crate) stroke: SingleColor,
pub(crate) stroke_width: f64,
pub(crate) outlier_color: SingleColor,
pub(crate) outlier_size: f64,
pub(crate) width: f64,
pub(crate) spacing: f64,
pub(crate) span: f64,
}
impl MarkBoxplot {
pub(crate) fn new() -> Self {
Self {
color: SingleColor::new("none"),
opacity: 1.0,
stroke: SingleColor::new("black"),
stroke_width: 1.0,
outlier_color: SingleColor::new("black"),
outlier_size: 3.0,
width: 0.5, spacing: 0.2, span: 0.7, }
}
pub fn with_color(mut self, color: impl Into<SingleColor>) -> Self {
self.color = color.into();
self
}
pub fn with_opacity(mut self, opacity: f64) -> Self {
self.opacity = opacity.clamp(0.0, 1.0);
self
}
pub fn with_stroke(mut self, stroke: impl Into<SingleColor>) -> Self {
self.stroke = stroke.into();
self
}
pub fn with_stroke_width(mut self, width: f64) -> Self {
self.stroke_width = width;
self
}
pub fn with_outlier_color(mut self, color: impl Into<SingleColor>) -> Self {
self.outlier_color = color.into();
self
}
pub fn with_outlier_size(mut self, size: f64) -> Self {
self.outlier_size = size;
self
}
pub fn with_width(mut self, width: f64) -> Self {
self.width = width;
self
}
pub fn with_spacing(mut self, spacing: f64) -> Self {
self.spacing = spacing.clamp(0.0, 1.0);
self
}
pub fn with_span(mut self, span: f64) -> Self {
self.span = span.clamp(0.0, 1.0);
self
}
}
impl Default for MarkBoxplot {
fn default() -> Self {
Self::new()
}
}
impl Mark for MarkBoxplot {
fn mark_type(&self) -> &'static str {
"boxplot"
}
}