#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[allow(dead_code)]
pub(crate) enum ChartKind {
Bar,
Line,
Area,
Pie,
Doughnut,
Scatter,
}
impl ChartKind {
#[allow(dead_code)]
pub(crate) fn parse(s: &str) -> Option<ChartKind> {
match s.to_lowercase().as_str() {
"bar" => Some(ChartKind::Bar),
"line" => Some(ChartKind::Line),
"area" => Some(ChartKind::Area),
"pie" => Some(ChartKind::Pie),
"doughnut" => Some(ChartKind::Doughnut),
"scatter" => Some(ChartKind::Scatter),
_ => None,
}
}
#[allow(dead_code)]
pub(super) fn chartjs_type(self) -> &'static str {
match self {
ChartKind::Bar => "bar",
ChartKind::Line | ChartKind::Area => "line",
ChartKind::Pie => "pie",
ChartKind::Doughnut => "doughnut",
ChartKind::Scatter => "scatter",
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[allow(dead_code)]
pub(crate) struct ChartSpec {
pub(crate) kind: ChartKind,
pub(crate) x: Option<String>, pub(crate) y: Vec<String>, pub(crate) title: Option<String>,
}