use crate::mark::Mark;
use crate::visual::color::SingleColor;
#[derive(Clone)]
pub struct MarkErrorBar {
pub(crate) color: SingleColor,
pub(crate) opacity: f64,
pub(crate) stroke_width: f64,
pub(crate) cap_length: f64,
pub(crate) show_center: bool,
pub(crate) width: f64, pub(crate) spacing: f64, pub(crate) span: f64, }
impl MarkErrorBar {
pub(crate) fn new() -> Self {
Self {
color: SingleColor::new("black"),
opacity: 1.0,
stroke_width: 1.0,
cap_length: 3.0,
show_center: false,
width: 0.5,
spacing: 0.0,
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_width(mut self, width: f64) -> Self {
self.stroke_width = width;
self
}
pub fn with_cap_length(mut self, length: f64) -> Self {
self.cap_length = length;
self
}
pub fn with_center(mut self, show: bool) -> Self {
self.show_center = show;
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 MarkErrorBar {
fn default() -> Self {
Self::new()
}
}
impl Mark for MarkErrorBar {
fn mark_type(&self) -> &'static str {
"errorbar"
}
}