mod ease;
mod extras;
mod math;
mod pie;
mod plot;
mod view;
pub use extras::{
ComparisonBuilder, ComparisonItem, HistogramBuilder, comparison_bar_chart, histogram,
spark_line, threshold_line_chart,
};
pub use pie::{PieBuilder, PieSlice, pie_chart};
pub use view::{ChartBuilder, area_chart, bar_chart, line_chart};
#[derive(Clone, Debug, PartialEq)]
pub struct ChartSeries {
pub name: String,
pub values: Vec<f64>,
pub color: Option<String>,
}
impl ChartSeries {
pub fn new(name: impl Into<String>, values: impl Into<Vec<f64>>) -> Self {
Self {
name: name.into(),
values: values.into(),
color: None,
}
}
pub fn color(mut self, css: impl Into<String>) -> Self {
self.color = Some(css.into());
self
}
}
#[derive(Clone, Debug, PartialEq)]
pub struct ChartBand {
pub from: f64,
pub to: f64,
pub color: Option<String>,
pub label: Option<String>,
}
impl ChartBand {
pub fn new(from: f64, to: f64) -> Self {
Self {
from,
to,
color: None,
label: None,
}
}
pub fn label(mut self, label: impl Into<String>) -> Self {
self.label = Some(label.into());
self
}
pub fn color(mut self, css: impl Into<String>) -> Self {
self.color = Some(css.into());
self
}
}
#[derive(Clone, Debug, PartialEq)]
pub struct ChartMarker {
pub value: f64,
pub color: Option<String>,
}
impl ChartMarker {
pub fn new(value: f64) -> Self {
Self { value, color: None }
}
pub fn color(mut self, css: impl Into<String>) -> Self {
self.color = Some(css.into());
self
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ChartCurve {
Linear,
#[default]
Smooth,
Step,
}