Переглянути джерело

Better tags repartition with TAG_CLOUD_MAX_ITEMS

WhiteWinterWolf 6 роки тому
батько
коміт
9c38b814b1
1 змінених файлів з 4 додано та 3 видалено
  1. 4 3
      tag_cloud/tag_cloud.py

+ 4 - 3
tag_cloud/tag_cloud.py

@@ -43,15 +43,16 @@ def generate_tag_cloud(generator):
 
     tags = list(map(itemgetter(1), tag_cloud))
     if tags:
-        max_count = max(tags)
+        max_count = tags[0]
+        min_count = tags[-1]
     steps = generator.settings.get('TAG_CLOUD_STEPS')
 
     # calculate word sizes
     def generate_tag(tag, count):
         tag = (
             tag,
-            int(math.floor(steps - (steps - 1) * math.log(count)
-                / (math.log(max_count)or 1)))
+            int(math.floor(steps - (steps - 1) * math.log(count - min_count + 1)
+                / (math.log(max_count - min_count + 1) or 1)))
         )
         if generator.settings.get('TAG_CLOUD_BADGE'):
             tag += (count,)