Render only 10 point text and 20 label text elements.

This commit is contained in:
Bauke 2023-06-07 20:21:13 +02:00
parent 207e021404
commit 2ef9289815
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
1 changed files with 8 additions and 2 deletions

View File

@ -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)