use textplots::{Chart, Plot, Shape};
fn main() {
println!("y = atan(x)");
Chart::default()
.lineplot(&Shape::Continuous(Box::new(|x| x.atan())))
.display();
println!("\ny = sin(x) / x");
Chart::default()
.lineplot(&Shape::Continuous(Box::new(|x| x.sin() / x)))
.display();
println!("\ny = ln(x)");
Chart::default()
.lineplot(&Shape::Continuous(Box::new(f32::ln)))
.display();
println!("\ny = cos(x), y = sin(x) / 2");
Chart::new(180, 60, -5.0, 5.0)
.lineplot(&Shape::Continuous(Box::new(|x| x.cos())))
.lineplot(&Shape::Continuous(Box::new(|x| x.sin() / 2.0)))
.display();
let points = [
(-10.0, -1.0),
(0.0, 0.0),
(1.0, 1.0),
(2.0, 0.0),
(3.0, 3.0),
(4.0, 4.0),
(5.0, 3.0),
(9.0, 1.0),
(10.0, -1.0),
];
println!("\ny = interpolated points");
Chart::default().lineplot(&Shape::Lines(&points)).display();
println!("\ny = staircase points");
Chart::default().lineplot(&Shape::Steps(&points)).display();
println!("\ny = scatter plot");
Chart::default().lineplot(&Shape::Points(&points)).display();
println!("\nRender to string (and then print that string)");
let mut chart = Chart::default();
let binding = Shape::Continuous(Box::new(|x| x.atan()));
let chart = chart.lineplot(&binding);
chart.axis();
chart.figures();
let chart_string = chart.to_string();
println!("{}", chart_string);
}