//! "Candlestick" plots use std::borrow::Cow; use std::iter::IntoIterator; use crate::data::Matrix; use crate::traits::{self, Data, Set}; use crate::{Color, Default, Display, Figure, Label, LineType, LineWidth, Plot, Script}; /// Properties common to candlestick plots pub struct Properties { color: Option, label: Option>, line_type: LineType, linewidth: Option, } impl Default for Properties { fn default() -> Properties { Properties { color: None, label: None, line_type: LineType::Solid, linewidth: None, } } } impl Script for Properties { fn script(&self) -> String { let mut script = String::from("with candlesticks "); script.push_str(&format!("lt {} ", self.line_type.display())); if let Some(lw) = self.linewidth { script.push_str(&format!("lw {} ", lw)) } if let Some(color) = self.color { script.push_str(&format!("lc rgb '{}' ", color.display())); } if let Some(ref label) = self.label { script.push_str("title '"); script.push_str(label); script.push('\'') } else { script.push_str("notitle") } script } } impl Set for Properties { /// Sets the line color fn set(&mut self, color: Color) -> &mut Properties { self.color = Some(color); self } } impl Set