-
Book Overview & Buying
-
Table Of Contents
ActionScript Graphing Cookbook
By :
In this recipe we are going to build a treemap. Treemaps are used to represent the data structure of a tree (nodes that have nodes as children). In this example, we are going to use it more as a rectangular pie chart. Wherever you can use a pie chart, you will be able to use this treemap, but it will give you the ability to use something a bit different.

Open the files in the Treemap folder in the downloadable code files from www.packtpub.com.
Let's start by creating the data structure that is TreemapData.as:
public var color : uint;
public var percent : Number;
public var label:String;
public function TreemapData(newPercent:Number, newColor:uint, newLabel:String) {
percent = newPercent;
color = newColor;
label = newLabel;
}From there we can jump to Treemap.as. We will need to inversely sort the data as our first step. To do so we will create a sorting function and pass it to the sort function of Array. The following is what the sorting...
Change the font size
Change margin width
Change background colour