You'll need to set a minimum size, so maybe fontsize = minsize + factor * percentage.
You may want to limit the range of sizes; perhaps take the sqrt or log of percentage, but this depends on your distribution.
For another technique, have a look at this blog post from poeticcode on Tag Clouds Algorithms:
Next, in the linear interpolation, how do we set the min and max boundaries for the font size/color intensity? I notice that Amazon.com for example, is ranging it’s font sizes between 80% and 280%. So, the lowest tag in the cloud would get a font size of 80% and the highest tag 280%. I have decided to go with the following formula
150*(1.0+(1.5*m-maxm/2)/maxm)
This nicely gives a font size from 75% to 300% as the metric changes from a potential 0 to maxm.
Next create CSS styles for 20 / 40 / 60 / 80 / 100 percentage values and apply the correct CSS style according to the percentage.
Or you could as you suggested calculate the font size.
First get your max. and min and calculate the spread. ($max - $min). Your font-size increment would be the "step" - which is basically ($max - $min) / $spread.
Now you can calculate your font-sizes accordingly:
发布评论
评论(4)
您需要设置最小尺寸,因此可能是
fontsize = minsize + Factor * Percent
。您可能想限制尺寸范围;也许采用百分比的平方根或对数,但这取决于您的分布。
对于另一种技术,请查看 Poeticcode 在 标签云上发表的博客文章算法:
You'll need to set a minimum size, so maybe
fontsize = minsize + factor * percentage
.You may want to limit the range of sizes; perhaps take the sqrt or log of percentage, but this depends on your distribution.
For another technique, have a look at this blog post from poeticcode on Tag Clouds Algorithms:
我会检查每个元素的出现情况并跟踪“最大值”(计数最高的元素,因为这将是您的度量)。
接下来计算每个元素与最大元素(即 100%)相比出现的百分比。例如:
接下来为 20 / 40 / 60 / 80 / 100 百分比值创建 CSS 样式,并根据百分比应用正确的 CSS 样式。
或者您可以按照您的建议计算字体大小。
首先得到你的最大值。和最小值并计算价差。 ($ 最大 - $ 最小)。您的字体大小增量将是“步长” - 基本上是 ($max - $min) / $spread。
现在您可以相应地计算字体大小:
不要忘记对结果进行四舍五入。
I'd check the occurance for every element and keep track of the "maximum" (the element with the highest count as this will be your measure).
Next calculate the percentage of occurance for each element, compared to the element with the maximum (which is 100%). For instance:
Next create CSS styles for 20 / 40 / 60 / 80 / 100 percentage values and apply the correct CSS style according to the percentage.
Or you could as you suggested calculate the font size.
First get your max. and min and calculate the spread. ($max - $min). Your font-size increment would be the "step" - which is basically ($max - $min) / $spread.
Now you can calculate your font-sizes accordingly:
Don't forget to round of your result.
可以写第二部分给你标记云实现最小值和最大值并传播我有点困惑。
Could write the second part to you tag cloud implementation min and max and spread Im a bit confused.
我已经进行了这样的标签云计算:
这允许您根据需要舍入字体大小。
字体大小永远不会超过 $minFSad $maxFS 的字体大小范围。
I've made tag cloud calculating like this:
This allow you to round font sizes depending of your need.
Font size will never exceed font size range of $minFSad $maxFS.