From 7b2c77b2d9342aeb0a553b89d0dda28290d744ed Mon Sep 17 00:00:00 2001 From: Bauke Date: Mon, 10 Jul 2023 17:49:15 +0200 Subject: [PATCH] Fix divide by zero errors. --- source/charts/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/charts/mod.rs b/source/charts/mod.rs index ba79d6d..1919caa 100644 --- a/source/charts/mod.rs +++ b/source/charts/mod.rs @@ -80,7 +80,7 @@ impl UserCountChart { .configure_mesh() .x_labels(datapoints.len() + 2) .x_label_formatter(&|x| { - if (x - 1) % (datapoints_len / 20) != 0 { + if (x - 1) % (datapoints_len / 20).max(1) != 0 { String::new() } else { format!("{:0}", datapoints_len - x) @@ -122,7 +122,7 @@ impl UserCountChart { ) + Text::new( { - if (x - 1) % (datapoints_len / 10) != 0 { + if (x - 1) % (datapoints_len / 10).max(1) != 0 { String::new() } else { format!("{:0}", y)