pub mod bar;
pub mod boxplot;
pub mod common;
pub mod gauge;
pub mod line;
pub mod matrix;
pub mod mixed;
pub mod pie;
pub mod polar_area;
pub mod progress;
pub mod radar;
pub mod scatter;
pub mod sparkline;
use crate::ir::{ChartKind, ChartSpec};
use crate::scene::{Prim, Scene};
use crate::text::TextMeasurer;
pub fn build_scene(spec: &ChartSpec, m: &TextMeasurer) -> Scene {
let mut scene = match spec.kind {
ChartKind::Bar { .. } => bar::build(spec, m),
ChartKind::Line => line::build(spec, m),
ChartKind::Pie { .. } => pie::build(spec, m),
ChartKind::PolarArea => polar_area::build(spec, m),
ChartKind::Scatter | ChartKind::Bubble => scatter::build(spec, m),
ChartKind::Radar => radar::build(spec, m),
ChartKind::Mixed => mixed::build(spec, m),
ChartKind::Matrix { .. } => matrix::build(spec, m),
ChartKind::Progress => progress::build(spec, m),
ChartKind::BoxPlot => boxplot::build(spec, m),
ChartKind::Sparkline => sparkline::build(spec, m),
ChartKind::RadialGauge { .. } | ChartKind::Gauge { .. } => gauge::build(spec, m),
};
if let Some(fill) = spec.theme.background {
scene.items.insert(
0,
Prim::Rect {
x: 0.0,
y: 0.0,
w: spec.width,
h: spec.height,
fill,
},
);
}
scene
}