Skip to content
/ treemaps Public

An open source ActionScript 3 library for generating Squarified Treemaps.

Notifications You must be signed in to change notification settings

arpit/treemaps

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

README

An open source ActionScript 3 library for generating Squarified Treemaps. The library is based on the algorithm by Mark Bruls, Kees Huizing, and Jarke J. van Wijk from the Eindhoven University of Technology, Dept. of Mathematics and Computer Science,The Netherlands. The paper can be found here: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.36.6685&rep=rep1&type=pdf

The library was used to build the DiggGraphr application mentioned here: http://infosthetics.com/archives/2009/01/digggraphr_digg_stories_in_a_treemap.html

Usage:

The example below uses a MapItem class that implements the ITreeMapData interface. The weight property on that interface is used to generate the relative size of the individual rectangles

Custom renderers can be used to draw the rectangles by extending the Treemap class and overriding the draw function.

package
{
	import com.arpitonline.treemap.TreeMap;

	import flash.display.Sprite;
	import flash.events.Event;

	public class SampleTreemapProject extends Sprite
	{

		private var tm:TreeMap = new TreeMap();

		public function SampleTreemapProject()
		{
			stage.scaleMode = "noScale";
			stage.align = "TL";


			tm.setSize(stage.stageWidth, stage.stageHeight);

			var dp:Array = [];
			for(var i:int = 0; i < 5; i++){
				var i1:MapItem = new MapItem("Item_"+i, 4 );
				dp.push(i1);

			}

			tm.dataProvider = dp;
			addChild(tm);

			stage.addEventListener(Event.RESIZE, onStageResize);

		}

		private function onStageResize(event:Event):void{
			tm.setSize(stage.stageWidth, stage.stageHeight);
			tm.layout();
		}
	}
}

import com.arpitonline.treemap.ITreeMapData;

class MapItem implements ITreeMapData{

	private var _label:String;
	private var _weight:Number
	public function MapItem(label:String, weight:Number){
		_label = label;
		_weight = weight;
	}

	public function get weight():Number{
		return _weight;	
	}
}

About

An open source ActionScript 3 library for generating Squarified Treemaps.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published