A strongly-typed rust interface to the https://napchart.com API.
The public napchart api is pretty barebones right now, but this will let you use it!
Add to your Cargo.toml:
text
[dependencies]
napchart = "0.3"
Example: https://napchart.com/snapshot/O6kunUfuL ``` use napchart::prelude::*;
let mut chart = Napchart::default() .shape(ChartShape::Circle) .lanes(1); let firstlane = chart.getlanemut(0).unwrap(); firstlane.addelement(0, 60).unwrap() .text("Hour One"); firstlane.addelement(180, 240).unwrap() .text("Hour Four"); let secondlane = chart.addlane(); secondlane.addelement(0, 120).unwrap() .color(ChartColor::Blue); secondlane.add_element(120, 240).unwrap() .color(ChartColor::Green) .text("Cool green time"); ```
Example Chart: https://napchart.com/3tbkt ``` use napchart::api::BlockingClient;
let client = BlockingClient::default(); let rchart = client.getchart("3tbkt").unwrap(); asserteq!(rchart.chartid, String::from("3tbkt")); asserteq!(rchart.title, Some(String::from("State test chart"))); asserteq!(rchart.chart.shape, napchart::ChartShape::Circle); asserteq!(rchart.chart.laneslen(), 1); ```
Example Output: https://napchart.com/snapshot/TpCfggr4i ``` use napchart::prelude::*; use napchart::api::BlockingClient;
let client = BlockingClient::default(); let mut chart = Napchart::default(); let lane = chart.addlane(); lane.addelement(420, 1260) .unwrap() .text("Nighttime") .color(ChartColor::Gray); let uploadbuilder = chart.upload() .title("readme doctest") .description("https://crates.io/crates/napchart"); let remotechart = client.createsnapshot(uploadbuilder).unwrap(); assert!(!remotechart.chartid.isempty()); ```