use charton::prelude::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let x_values: Vec<f64> = (0..30).map(|i| i as f64 * 0.2).collect();
let y_sine: Vec<f64> = x_values.iter().map(|&x| x.sin()).collect();
let y_cosine: Vec<f64> = x_values.iter().map(|&x| x.cos()).collect();
let x = x_values.repeat(2); let y = [y_sine.clone(), y_cosine.clone()].concat();
let category = [vec!["Sine"; 30], vec!["Cosine"; 30]].concat();
chart!(x, y, category)?
.mark_line()?
.configure_line(|l| l.with_loess(true).with_loess_bandwidth(0.2))
.encode((
alt::x("x"),
alt::y("y"),
alt::color("category"), ))?
.configure_theme(|t| t.with_x_tick_label_angle(-45.0))
.coord_flip()
.save("docs/src/images/line.svg")?;
Ok(())
}