changeset 1076:b8d7683ec05a default tip

sidebar: use a logarithmic tagcloud scaling Instead of linearly scaling the tagcloud entries based on their counts, scale it based on the 2 times the natural log of the count. This gives more weight to lower count tags, making the whole cloud looking "denser". Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Fri, 28 Aug 2020 03:31:08 +0000
parents fd4337f68e43
children
files sidebar.c
diffstat 1 files changed, 3 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/sidebar.c	Thu Jul 30 16:53:56 2020 -0400
+++ b/sidebar.c	Fri Aug 28 03:31:08 2020 +0000
@@ -45,11 +45,10 @@
 	if (count <= cmin)
 		return config.tagcloud_min_size;
 
-	size  = (config.tagcloud_max_size - config.tagcloud_min_size) *
-		(count - cmin);
-	size /= (float) (cmax - cmin);
+	size = 2 * log(count - cmin);
 
-	return ceil(config.tagcloud_min_size + size);
+	return MIN(ceil(config.tagcloud_min_size + size),
+		   config.tagcloud_max_size);
 }
 
 static int __tagcloud_init(void *arg, unsigned long ntags)