LATEST VERSION AND DOCUMENTATION AVAILABLE HERE
I’ve been looking for a component that could show Wordle style word clouds. The only Silverlight component I could find was Infragistics xamTagCloud, but it really didn’t produce the output I was looking for. What I wanted was to be able to put lower importance words within the spaces left around larger entries.
Having looked around the web I couldn’t find a component to buy or borrow so I decided to write my own.
I came across this post on Stack Overflow that had a response from the author of Wordle (Jonathan Feinberg), giving some tips on how Wordle works. I used that and the extra reference Jonathan provided to build my component.
The key to word layout is to use a spiral (or another progressive positioning equation) to try to position words, every new word needs to be checked against the previously placed items to ensure that there is no overlap.
As collision is the expensvie part of the algorithm Jonathan suggests using a variety of techniques around collision rectangles and space partitioning to do the item testing; I felt this wasn’t necessary for my needs so I actually test the overlapping pixels to see if there is a hit. This seems to give good enough performance, and if I wanted to improve it I would advocate making a second collision map at a lower resolution (1/8 scale) that would significantly cut down on the processing – but again, wasn’t necessary for me.
If you want to use something to layout instead of my spiral, you need to replace the GetSpiralPoint function with something that will return a progressive space based on an increaseing angle measured in radians.
The component also supports word hit testing and selection as well as coloring words based on a value as well as sizing them.
You can download the full source code for the component and the test project which will allow you to play with the parameters from the link at the top of this post.



Mike Talbot is Chief Visionary of 3radical. He started his career as a game programmer working for UbiSoft and Electronic Arts among others. Currently he is programming mobile applications in Javascript, HTML5 and ASP.NET.
email: 
#1 by gmamaladze on August 4, 2011 - 7:28 pm
Hi !
Really good job.
I am currently working on an open source project which uses word cloud for code visualization see http://sourcecodecloud.codeplex.com.
My focus was rather on very performant analyses of text data then on visual beauty. So my cloud is in GDI+ and it looks ok but not as nice as yours.
What about joining our project to take care on silverlight branch of the app? Otherwise I would ask you to give us permission to take your code as first shot?
I did not fount any license disclaimer on it here. Which license would you apply to your code? We publish our component under Microsoft Public License (Ms-PL). Is it ok for you?
Thanks in advance
George
#2 by whydoidoit on August 5, 2011 - 9:00 am
Hi George,
My welcome message says you can use the code here for anything, I figure I ought to just stick the Ms-PL in there though for good measure.
I’m going to upload a new version soon, this supports individual word coloring, word angles and has a slightly better spacing technique. It uses the 2 level collision mapping for a performance improvement. Should post in the next day or so. You are welcome to take the code and use it as you see fit, if I can help with anything then just let me know
Best
Mike
#3 by whydoidoit on August 17, 2011 - 9:19 pm
Updated version now available
#4 by Matt on August 16, 2011 - 9:09 pm
Mike… Nice job!! Any word on the new version?
#5 by whydoidoit on August 16, 2011 - 10:55 pm
Yeah, sorry, been busy with Silverlight Serializer and haven’t got round to extracting and uploading it – should be up in the next 48 hours.
#6 by whydoidoit on August 17, 2011 - 9:20 pm
New version uploaded, and a new page created with some docs.