DiggMapper: Visualizing Digg data using Treemaps

This is definitely work in progress. I ported my treemap classes to the Flex framework and created this quick app that reads data from Digg. It doesnt automatically load data so click on one of the links above to get started. Rollover the rectangles to preview the story and click on them to launch the link. I just love the visualization since it makes so much more sense of the number of diggs than just the number on next to the story. For example the image below just underlines the importance of Halo3 in the gaming community so much more than seeing the number in a list (click to enlarge)

Digg game news at 9:30 EST

You can try the DiggMapper here. Its still incomplete but if you have any suggestions, please leave them as a comment

Squarified Treemaps with source !!

Treemaps (sometimes called heatmaps) are one of my favorite data visualization techniques, and it has taken me a while to finally figure out how to do them. The idea is simple: Each component is represented by a rectangle whose area is proportional to the ‘weight’ or relative importance of the item. I finally did find a technical paper on the idea and have implemented it in my source code. The algorithm efficiently finds what the best dimensions should be for the rectangle keeping its length-to-width ratio as close to one as possible. The demo application reads Digg’s music news feed and draws rectangled based on the number of diggs each entry got. To really play with the application, resize the container and see the application redraw itself to respond to the change in dimensions. I think the coolest part of the code is the fact that the drawing part is fairly abstracted from the logic that computes the sizing. So to create your own ‘renderer’, all you have to do is extend the HLayoutManager and the VLayoutManager and override the draw method.

The code is released under the MIT liscense, so feel free to use it.

The DiggReader application can be seen here and the source can be seen here. Use the DiggReader.as as main class of the DiggReader application

[Update: The latest version of the library is now on GitHub. The new version decouples the dependency on nested Sprites and gives you a lot more control on elements you’d like to lay out. Also check out some fantastic examples using the library by nicoptere]

Numbered List: Take Two

I had posted yesterday how I had managed to use the listData property to add numbers to the list item renderer. However this technique broke when the List actually extended beyond viewable area and became scrollable. I have the updated the example to reflect the fix but here is what I learned during the entire process.

1) The list draws out as many itemRenderers as can be rendered if the dataProviders length is more than the numbers that can be drawn on the list without scolling.
2) List item sets the data value of the item renderer.
3) If the renderer extends IDropInListItemRenderer interface, the list sets the listData value on the renderer. The listData gives some more info to the renderer such as what its row index is,etc.
4)When the user scrolls the list, the labels are rewritten on the same renderers without actually drawing new renderers.

To actually implement the numbering, I ended up using the renderer’s owner property to get a reference on the List and then using the itemRendererToIndex method on the List passing it itself as the parameter. This now works much better as you can see. Right-click to view source :).

Drag-Move Enabled Numbered Lists

One design I am working on required a numbered list with a custom renderer and drag-move enabled. I had no idea how to do this the right way and it took me a couple of hours to finally get it. So I have released the source here just in case anyone else ever needs something similar.

I originally thought the List class was something like the Repeater class. Had it been, the instanceIndex property of the UIComponent would have been the simplest way to implement the feature. Unfortunately, the List doesn’t use Repeater at all. The key is actually the listData property on the renderer that the parent List tries to set on the renderer but only if the renderer implements the IDropInListItemRenderer.

Anyway, take a look at the implementation (right click to view source) – its pretty self-explanatory. I have set it drag/drop enabled but this implementation keeps the numbering correct.

TileList Creativity …

I love to break out of the Flex look whenever I can. Flex does give me a lot of functionality that I don’t have to write from scratch in AS3 but for entertainment oriented applications, the default look doesn’t always work. Of course, being lazy, I always love it when I can make something look interesting without that much work.

So here is a rather simple extension to the TileList component that adds some personality to it. The code is simple enough, I just randomly add a small rotation to the images to give it more of a scattered deck of images look rather than a standard grid. A custom cell renderer adds to the effect. I have also added a ‘hover to see larger image’ thing there but that part isn’t completely done yet and so the images are getting clipped but its an interesting experiment on creating custom toolTips.

Check it out here and right click to view source.

Recommendation Systems

Of late, I have started reading quite a bit on Recommendation Systems and I came accross this interesting paper on the topic. The cool thing is that it talks about virtual co.mmunities based on recommendation systems (I am sure Amazon uses a similar algorithm, since this seems pretty common sense).

On a side note, the paper did lead me to finding out what a Pearson’s Correlation is. Pretty neat. Further links on this entry as I come across ’em

Links:
Content-Boosted Collaborative Filtering
Bunch o’ papers

Foiled !!!

This is why I don’t take long vacations ;). I just got back from a long one to discover every inch of my office covered in aluminum foil, courtesy Aaron( my manager, thats him in the black shirt) and a bunch of other developers. Apparently I got away easy since some of the other ideas were so much more…umm..creative :D.

I love working in a fun group.

[Update] And then there was the next year. I really gotta stop taking vacations ๐Ÿ˜‰

Squarified Treemaps

This has been something I have wanted to do for a while but I needed some guidance on the theory. Of course the treemap has been done a few times before (I think I saw the first implementation by marumushi I still love the design there. Since then I have seen it on a couple of other sites including CNet news). I also remember reading somewhere about someone about to release a TreeMap Flex component but I have no idea how long that will take or under what license terms. Plus I always have more trust in code I wrote since I’ll be able to debug it faster if I have to.

I am not publishing the source as yet since its needs some code cleanup, but you can look at the demo here. I have some data baked into the swf ([10,10,9,8,6,6,4,3,2,2,1]). The component then creates a series of rectangles with relative sizes reflecting the values. I have also added a redraw function listening on Stage resize, so try resizing the browser window and see how the code redraws the rectangles.

Source coming soon ๐Ÿ™‚

Skinning the Flex 2 Slider component

The skinning capabilities of Flex 2 components has been criticized quite a bit. There are a few articles on devnet that discuss this a bit but I have to say that skinning components really does require some effort.

The problem is that Flex tries to be the framework for everything and of course everyone’s requirement is just slightly different. Flash was always a language for personal expression and a lot of people have the same expectations for Flex (Hardly anyone asks the Java Swing developers for scrollbars that look drastically different from the basic look and feel). To do Flex justice, compare the pain of skinning Flex components to creating a new look-and-feel for the Swing widget set.

Enough philosophy though, here is my first attempt to actually skin the Slider component (Right-click to view source). Couple of points that struck me were:
1) Make sure your components report the correct dimensions to the measurement architecture. I am still fuzzy on that part but the component wasnt working correctly until I added the measure() implementation on the SliderButton class.
2) The slider scrub positions the scrub button at an x of width/2. The width/2 point is also used as the point to set the value the slider reports.
3) This is definitely wrong and I hope the Flex team fixes this: The Slider class puts the highlight track at 1 pixel below the progress track. This definitely needs to be configurable without extending the Slider base class itself.

As always, comments are always welcome.

TabNavigator Update: Draggable Tabs

Of course I had to do this but this was much easier. Now you can drag the tabs to reorder them. Works pretty well. The one thing that seems lacking is instant notification where the new tab is going (on MouseMove), like FireFox brings up a purple arrow at the point where the tab is going. I dont know if I have the time for that, especially since it doesn’t seem like I will be using this container for my project, but the implementation should be simple.

Check the swf out here, and right click to view source.

If you are using this in a commercial app or something make sure you catch history management errors since removing tabs screws up history before that event (there isnt a tab-add undo when you click back ๐Ÿ˜‰ ), and brings up the error stack trace if you are running the debug player.

Hope this helps someone :).

[Update]ร‚ย Responding to a query from someone, this code is released under the MIT license. You can download/fork the code from the GitHub Repository