It seems that I’m on a Flex component development streak lately. A couple days ago, I got some inspiration to give a little attention to my TreeMap Flex component. After initially starting on some minor performance enhancements, I kept finding more and more I could do. Several commits later, I realized I was putting together a very solid new release.
Most interesting of this release’s additions are the performance enhancements. I hadn’t expected to improve the performance much more than what I was able to achieve moving from the 1.x archtecture to the 2.x architecture. However, some extra time spent in the profiler, along with some inspiration from a blog post on Flash Player’s dirty rectangle by Seb Lee-Delisle (the problem he overcame wasn’t directly related to what I optimized, but it made me think about improving the way I use certain display list functions) gave me a noticeable speed increase for larger data sets over 500 items.
Another big improvement is a new implementation of the default “Squarify” layout algorithm. The original version of this algorithm, and the one that most people implement in other open source treemap projects, is recursive. As I discovered, with a large enough data provider (between 1100-1200 items), the algorithm can easily cause a stack overflow in Flash Player. I rewrote the algorithm to run in a simpler while loop, so the number of items in the TreeMap’s data provider won’t be a bottleneck anymore. This change has a positive side effect; by removing so many function calls (which have a certain performance overhead), the algorithm ends up running a bit faster.
Those are the most interesting improvements. Others include the addition of properties for separately specifying branch labels and data tips (for instance, branchLabelField
takes precedence over labelField
), better (and faster) skins for leaf renderers, proper non-interactive behavior when enabled
is set to false (I always forget to test that when I build components), a new branchZoom
event on TreeMap, more complete API documentation, and a new example named Introduction to TreeMap (pictured above) that combines, streamlines, and replaces a few of the older examples.
Like what you see? Download flextreemap from the project page. The download includes the component SWC, documentation, compiled examples, and the full source code licensed under a widely-usable MIT license. The TreeMap API documentation is also available livedocs-style online, and you can view the examples there too. and if you find any bugs in the component, the documentation, or the examples, please file a bug report. Feature requests are welcome too.
Important note: TreeMap now requires Flex 3.2.0 at the minimum. The leaf renderer is very similar to a button, and I followed some of the conventions the Flex team are using to implement the Marshall Plan as it relates to mouse events and sandboxing. Some of the APIs involved don’t appear in earlier SDKs, so you must use Flex 3.2 or higher starting with TreeMap 2.1.0.