splot

Crates.iosplot
lib.rssplot
version0.4.0
sourcesrc
created_at2021-07-24 13:23:51.529177
updated_at2024-10-23 13:25:16.370292
descriptionPlot data to HTML
homepage
repositoryhttps://github.com/DougLau/splot
max_upload_size
id426773
size62,629
Douglas Lau (DougLau)

documentation

README

splot

Plot data to HTML / SVG

  • Simple but powerful API
  • Styling using CSS
  • Usable in WebAssembly

Line Plot

use splot::{Chart, Domain, Edge, Page, Plot};

let data = vec![(13, 74), (111, 37), (125, 52), (190, 66)];
let page = Page::new().chart(
    Chart::new()
        .title("Line Plot")
        .domain(Domain::from(&data[..]).set_x(&[0.0, 200.0]))
        .axis("X Axis", Edge::Bottom)
        .axis("Y Axis", Edge::Right)
        .plot(Plot::line("Series", &data)),
);
println!("{page}");

Scatter Plot

use splot::{Chart, Edge, Page, Plot};

let data_a = vec![(13, 74), (111, 37), (125, 52), (190, 66)];
let data_b = vec![(22, 50), (105, 44), (120, 67), (180, 39)];
let page = Page::new().chart(
    Chart::new()
        .title("Scatter Plot")
        .domain(&data_a[..])
        .axis("X Axis", Edge::Bottom)
        .axis("Y Axis", Edge::Left)
        .axis("", Edge::Right)
        .plot(Plot::scatter("Series A", &data_a).label())
        .plot(Plot::scatter("Series B", &data_b)),
);
print!("{page}");
Commit count: 86

cargo fmt