开发者

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:

开发者_C百科
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?


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/


Try i2ui for this issue:

  1. Define font range.
  2. Set up the rates for tags.

    <div data-i2="css:[{fontSize:'8px'},{fontSize:'25px'}]">
        <span data-i2="rate:1">Word1</span>
        <span data-i2="rate:82">Word2</span>
        <span data-i2="rate:-5">Word3</span>
        <span data-i2="rate:12">Word4</span>
    </div>
    

Demo: http://jsfiddle.net/x4558/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜