From dc13122476dbd9c464081c5f1cd87b18b5e13f3f Mon Sep 17 00:00:00 2001 From: Joscha Date: Mon, 23 Jan 2023 13:04:01 +0100 Subject: [PATCH] Add args for chart size --- src/main.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index e3b195e..843b11a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,6 +9,10 @@ struct Args { /// Path to a git repository. #[arg(default_value = ".")] repo: PathBuf, + #[arg(long, short, default_value_t = 300)] + width: u32, + #[arg(long, short, default_value_t = 150)] + height: u32, } fn count_lines(repo: &Repository, commit: &Commit) -> anyhow::Result { @@ -46,9 +50,15 @@ fn main() -> anyhow::Result<()> { .map(|(i, l)| (i as f32, l as f32)) .collect::>(); - let mut chart = Chart::new_with_y_range(200, 100, 0_f32, xmax as f32, 0_f32, ymax as f32); - chart.nice(); - chart.lineplot(&Shape::Lines(&lines)).display(); + let mut chart = Chart::new_with_y_range( + args.width, + args.height, + 0_f32, + xmax as f32, + 0_f32, + ymax as f32, + ); + chart.lineplot(&Shape::Lines(&lines)).nice(); Ok(()) }