How to create a Simple tag cloud? Using C# and Styling with css

亡梦爱人 提交于 2019-12-13 03:59:22

问题


I'm finding it impossible to create a tag cloud, I can't find any walkthrough’s or tutorials. (ones that work at least).

I'm just looking for a simple, basic example of a working tag cloud and I can spice it up after that.

The best link i found is:

http://www.geekzilla.co.uk/View960C74AE-D01B-428E-BCF3-E57B85D5A308.htm

But it's out dated and I can't download the source file, and there are many gaps in the code.


回答1:


This isn't a really hard problem. Essentially a tag cloud is just a way of linking the fontsize to the how common the tag is.

First thing is how often does the tag appear:

select Value, Count(*)
from Tag
group by Value
order by Count(*)

Then when you render this resultset to the page, have some sort of algorithm to take the count for each tag and represent it as a font size. A naive approach would be to set the fontsize directly to the count, but that's likely to lead to unreadable results. Instead, perhaps just have the top 10% as a large font, the next 10% as the next fontsize down, etc. You'll have to work out an exact algorithm that works for you and your data, though.

Also, tag clouds are really a bit rubbish from several points of view (readability, searching, accessibility). Make sure the tag cloud isn't the only way to get access to the tags. Perhaps in alpha order or by Count(*) on a dedicated page.




回答2:


Use the TermCloud from the Google Charts API. It's very easy to use and it renders beautifully.



来源:https://stackoverflow.com/questions/10580508/how-to-create-a-simple-tag-cloud-using-c-sharp-and-styling-with-css

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!