From 2ef928981594d6ada128fa04ffd04f0bb8dd4c65 Mon Sep 17 00:00:00 2001 From: Bauke Date: Wed, 7 Jun 2023 20:21:13 +0200 Subject: [PATCH] Render only 10 point text and 20 label text elements. --- source/charts/mod.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source/charts/mod.rs b/source/charts/mod.rs index 47d48e1..61e94a2 100644 --- a/source/charts/mod.rs +++ b/source/charts/mod.rs @@ -77,7 +77,13 @@ impl UserCountChart { chart .configure_mesh() .x_labels(datapoints.len() + 2) - .x_label_formatter(&|x| format!("{:0}", datapoints_len - x)) + .x_label_formatter(&|x| { + if (x - 1) % (datapoints_len / 20) != 0 { + String::new() + } else { + format!("{:0}", datapoints_len - x) + } + }) .x_desc("N days ago") .y_labels(5) .y_label_formatter(&|y| format!("{y:0}")) @@ -114,7 +120,7 @@ impl UserCountChart { ) + Text::new( { - if (x - 1) % 2 != 0 { + if (x - 1) % (datapoints_len / 10) != 0 { String::new() } else { format!("{:0}", y)