algorithmmathtagstag-cloud

What is the formula to calculate the font-size for tags in a tagcloud?


I have a tag cloud and I need to know how can I change the font-size for the most used tags.

I need to set a min-font-size and a max-font-size.


Solution

  • You could use a linear or logarithmic assessment of the number of items associated with a certain tag relative to the largest tag, multiply it by the difference between minimum and maximum font sizes, then add it to the minimum font size. For example, the math in pseudocode might be:

    let min = 12, max = 24
    for each tag
        font = (items / items in biggest tag) * (max - min) + min