Search code examples
htmlruby-on-railsfontscluster-analysistag-cloud

Choose font sizes for tag cloud (rails3)


I would like to set font sizes for tags based on rating. This is what my sample ratings look like:

206 82 25 24 25 19 8 5 0 3 2 1 6 1 1 0 32 6 3 -1 112 31 6 8 2 24 18 2 2 1
1 1 2 6 67 35 37 25 0 1 7 8 2 3 0 1 2 1 -2 8 19 -2 1 1 -3 -4 6 1 1 8 11 3
1 3 1 2 5 1 0 1 1 2 2 2 1 2 2 1 1 1 1 1 0 1 1 2 1 2 1 1 0 1 1 2 1 1 1 1 1
1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 -1 0 1 -1 -1 1 -1 -1 0 -5
-1 2 2

I've tried using k-means clustering (gem) but I can't seem to pick the right number of centroids because my ratings vary from case to case. Also, I'm not sure what font range to use. What's the best way to do this?


Solution

  • Here you will find an algorithm for font sizes using logarithmic scaling based on the number of occurrences of each tag: http://blogs.dekoh.com/dev/2007/10/29/choosing-a-good-font-size-variation-algorithm-for-your-tag-cloud/