-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from uandere/master
Added axis labels formatting; Height and width limits changed; Axis are now rendered before the graph to prevent artifacts on colored diagrams;
- Loading branch information
Showing
4 changed files
with
108 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,3 +30,5 @@ rgb = "0.8.27" | |
[dev-dependencies] | ||
ctrlc = "3" | ||
console = "0.15.7" | ||
chrono = "0.4.30" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use chrono::{NaiveDate, Duration}; | ||
use textplots::{Chart, Shape, LabelBuilder, LabelFormat, ColorPlot}; | ||
|
||
fn main() { | ||
// Specify how labels are displayed. | ||
let start = NaiveDate::from_ymd_opt(2023, 6, 1).unwrap(); | ||
|
||
let end = NaiveDate::from_ymd_opt(2023, 9, 1).unwrap(); | ||
|
||
println!("My step count over 3 months: "); | ||
Chart::new_with_y_range(200, 50, 0.0, (end - start).num_days() as f32, 0.0, 25_000.0) | ||
.linecolorplot(&Shape::Continuous(Box::new(|x| 1000.0 * (5.0 * (0.5 * x).sin() + 0.05 * x) + 9000.0)), rgb::RGB { r: 10, g: 100, b: 200 }) | ||
.x_label_format(LabelFormat::Custom(Box::new(move |val| {format!("{}", start + Duration::days(val as i64))}))) | ||
.y_label_format(LabelFormat::Value) | ||
.display(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters