use crate::core::Result;
use crate::prelude::*;
use std::path::Path;
#[deprecated(
since = "0.6.0",
note = "use the Plot builder: Plot::new().line(x, y).save(path)"
)]
pub fn line_plot<P: AsRef<Path>>(x: &[f64], y: &[f64], path: P) -> Result<()> {
Plot::new().line(&x, &y).auto_optimize().save(path)
}
#[deprecated(
since = "0.6.0",
note = "use the Plot builder: Plot::new().line(x, y).title(title).save(path)"
)]
pub fn line_plot_with_title<P: AsRef<Path>>(
x: &[f64],
y: &[f64],
title: &str,
path: P,
) -> Result<()> {
Plot::new()
.line(&x, &y)
.title(title)
.auto_optimize()
.save(path)
}
#[deprecated(
since = "0.6.0",
note = "use the Plot builder: Plot::new().scatter(x, y).save(path)"
)]
pub fn scatter_plot<P: AsRef<Path>>(x: &[f64], y: &[f64], path: P) -> Result<()> {
Plot::new().scatter(&x, &y).auto_optimize().save(path)
}
#[deprecated(
since = "0.6.0",
note = "use the Plot builder: Plot::new().scatter(x, y).title(title).save(path)"
)]
pub fn scatter_plot_with_title<P: AsRef<Path>>(
x: &[f64],
y: &[f64],
title: &str,
path: P,
) -> Result<()> {
Plot::new()
.scatter(&x, &y)
.title(title)
.auto_optimize()
.save(path)
}
#[deprecated(
since = "0.6.0",
note = "use the Plot builder: Plot::new().bar(categories, values).save(path)"
)]
pub fn bar_chart<P: AsRef<Path>>(categories: &[&str], values: &[f64], path: P) -> Result<()> {
Plot::new()
.bar(categories, &values)
.auto_optimize()
.save(path)
}
#[deprecated(
since = "0.6.0",
note = "use the Plot builder: Plot::new().bar(categories, values).title(title).save(path)"
)]
pub fn bar_chart_with_title<P: AsRef<Path>>(
categories: &[&str],
values: &[f64],
title: &str,
path: P,
) -> Result<()> {
Plot::new()
.bar(categories, &values)
.title(title)
.auto_optimize()
.save(path)
}
#[deprecated(
since = "0.6.0",
note = "use the Plot builder: Plot::new().histogram(data).save(path)"
)]
pub fn histogram<P: AsRef<Path>>(data: &[f64], path: P) -> Result<()> {
Plot::new().histogram(&data).auto_optimize().save(path)
}
#[deprecated(
since = "0.6.0",
note = "use the Plot builder: Plot::new().histogram(data).title(title).save(path)"
)]
pub fn histogram_with_title<P: AsRef<Path>>(data: &[f64], title: &str, path: P) -> Result<()> {
Plot::new()
.histogram(&data)
.title(title)
.auto_optimize()
.save(path)
}
#[cfg(test)]
#[allow(deprecated)]
mod tests {
use super::*;
#[test]
fn test_simple_api_exists() {
let _ = line_plot::<&str>;
let _ = scatter_plot::<&str>;
let _ = bar_chart::<&str>;
let _ = histogram::<&str>;
}
#[test]
fn deprecation_notes_name_chains_that_compile() {
let x = vec![0.0, 1.0, 2.0];
let y = vec![0.0, 1.0, 4.0];
let categories = ["A", "B", "C"];
let values = vec![1.0, 2.0, 3.0];
let data = vec![1.0, 2.0, 2.0, 3.0];
let _ = Plot::new().line(&x, &y);
let _ = Plot::new().line(&x, &y).title("t");
let _ = Plot::new().scatter(&x, &y);
let _ = Plot::new().scatter(&x, &y).title("t");
let _ = Plot::new().bar(&categories, &values);
let _ = Plot::new().bar(&categories, &values).title("t");
let _ = Plot::new().histogram(&data);
let _ = Plot::new().histogram(&data).title("t");
}
}