I've got quite a puzzle for ya mathematicians here :)
This could go in the regular stackoverflow but since the subject matter of the question is primarily math I figure I'd ask it here.
I wasn't satisfied with any of the keyword cloud plugins I could find so I quickly hacked my own. Here is what the output of it looks like:
And here is the code:
<span style="border-bottom:1px dotted #eee;padding-left:3px;padding-right:3px;font-size:'+Math.log(((triggered_keywords[key]/total)*1300))+'em;">'+key+'</span> '
I'll copy just the math portion here:
So, I have an array of values like: [['watch', 5300], ['sky', 521], ['gas', 34]] I add them all together, divide each by the total and so for each keyword I arrive at a number.
(If you're curious, these words and the numbers represent search queries and the corresponding number of times they've been triggered)
I slept through my intro to calc class when I went to college but I sort of thought, hey, log() should help me "tame" the larger numbers so to speak. I added the *1300 in a series of trial and errors and made it look more or less nice.
As you can see some of the words though are being rendered tiny (with an em font-size of under 1). Is there a way to modify my "formula" to introduce a cap on how small a value will will come out?
I don't want the output number for any keyword to be smaller than about 0.85