use crate::scale::ScaleTrait;
use std::sync::Arc;
#[derive(Debug, Clone)]
pub struct AestheticMapping {
pub field: String,
pub scale_impl: Arc<dyn ScaleTrait>,
}
pub struct GlobalAesthetics {
pub color: Option<AestheticMapping>,
pub shape: Option<AestheticMapping>,
pub size: Option<AestheticMapping>,
}
impl GlobalAesthetics {
pub fn new(
color: Option<AestheticMapping>,
shape: Option<AestheticMapping>,
size: Option<AestheticMapping>,
) -> Self {
Self { color, shape, size }
}
pub fn get_mappings_for_field(&self, field_name: &str) -> Vec<(&str, &AestheticMapping)> {
let mut found = Vec::new();
if let Some(ref m) = self.color
&& m.field == field_name
{
found.push(("color", m));
}
if let Some(ref m) = self.shape
&& m.field == field_name
{
found.push(("shape", m));
}
if let Some(ref m) = self.size
&& m.field == field_name
{
found.push(("size", m));
}
found
}
}