//! Filled curve plots use std::borrow::Cow; use std::iter::IntoIterator; use crate::data::Matrix; use crate::traits::{self, Data, Set}; use crate::{Axes, Color, Default, Display, Figure, Label, Opacity, Plot, Script}; /// Properties common to filled curve plots pub struct Properties { axes: Option, color: Option, label: Option>, opacity: Option, } impl Default for Properties { fn default() -> Properties { Properties { axes: None, color: None, label: None, opacity: None, } } } impl Script for Properties { // Allow clippy::format_push_string even with older versions of rust (<1.62) which // don't have it defined. #[allow(clippy::all)] fn script(&self) -> String { let mut script = if let Some(axes) = self.axes { format!("axes {} ", axes.display()) } else { String::new() }; script.push_str("with filledcurves "); script.push_str("fillstyle "); if let Some(opacity) = self.opacity { script.push_str(&format!("solid {} ", opacity)) } // TODO border shoulde be configurable script.push_str("noborder "); 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 { /// Select axes to plot against /// /// **Note** By default, the `BottomXLeftY` axes are used fn set(&mut self, axes: Axes) -> &mut Properties { self.axes = Some(axes); self } } impl Set for Properties { /// Sets the fill color fn set(&mut self, color: Color) -> &mut Properties { self.color = Some(color); self } } impl Set