Treemap.js

Implements the TM class and other derived classes.

Description

A Treemap is an information visualization technique, proven very useful when displaying large hierarchical structures on a constrained space.  The idea behind a Treemap is to describe hierarchical relations as ‘containment’.  That means that if node B is child of node A, then B ‘is contained’ in A.

Inspired by

Squarified Treemaps (Mark Bruls, Kees Huizing, and Jarke J. van Wijk)

http://www.win.tue.nl/~vanwijk/stm.pdf

Tree visualization with tree-maps: 2-d space-filling approach (Ben Shneiderman)

http://hcil.cs.umd.edu/trs/91-03/91-03.html

Disclaimer

This visualization was built from scratch, taking only these papers as inspiration, and only shares some features with the Treemap papers mentioned above.

Summary
Treemap.jsImplements the TM class and other derived classes.
TMAbstract Treemap object.
Functions
eachTraverses head and leaf nodes applying a given function
createBoxConstructs the proper DOM layout from a json node.
plotRenders the Treemap.
headBoxCreates the head div dom element that usually contains the name of a parent JSON tree node.
bodyBoxCreates the body div dom element that usually contains a subtree dom element layout.
contentBoxCreates the content div dom element that usually contains a leaf div dom element or head and body div dom elements.
leafBoxCreates the leaf div dom element that usually contains nothing else.
setColorCalculates an hexa color string based on the $color data node property.
enterSets the elem parameter as root and performs the layout.
onLeftClickSets the elem parameter as root and performs the layout.
outSets the parent node of the currently shown subtree as root and performs the layout.
onRightClickSets the parent node of the currently shown subtree as root and performs the layout.
viewSets the root of the treemap to the specified node id and performs the layout.
resetPathSets an ‘in-path’ className for leaf and head elements which belong to the path between the given tree node and the visualization’s root node.
initializeElementsTraverses the DOM tree applying the onCreateElement method.
destroyElementsTraverses the tree applying the onDestroyElement method.
emptyEmpties the Treemap container (trying also to garbage collect things).
loadTreeLoads the subtree specified by id and plots it on the layout container.
TM.SliceAndDiceA JavaScript implementation of the Slice and Dice Treemap algorithm.
Functions
loadJSONLoads the specified JSON tree and lays it on the main container.
computeCalled by loadJSON to calculate recursively all node positions and lay out the tree.
TM.AreaAbstract Treemap class containing methods that are common to aspect ratio related algorithms such as TM.Squarified and TM.Strip.
Functions
loadJSONLoads the specified JSON tree and lays it on the main container.
computeDimComputes dimensions and positions of a group of nodes according to a custom layout row condition.
worstAspectRatioCalculates the worst aspect ratio of a group of rectangles.
avgAspectRatioCalculates the average aspect ratio of a group of rectangles.
TM.SquarifiedA JavaScript implementation of the Squarified Treemap algorithm.
Functions
computeCalled by loadJSON to calculate recursively all node positions and lay out the tree.
processChildrenLayoutComputes children real areas and other useful parameters for performing the Squarified algorithm.
squarifyPerforms an heuristic method to calculate div elements sizes in order to have a good aspect ratio.
layoutRowPerforms the layout of an array of nodes.
TM.StripA JavaScript implementation of the Strip Treemap algorithm.
Functions
computeCalled by loadJSON to calculate recursively all node positions and lay out the tree.
processChildrenLayoutComputes children real areas and other useful parameters for performing the Strip algorithm.
stripifyPerforms an heuristic method to calculate div elements sizes in order to have a good compromise between aspect ratio and order.
layoutRowPerforms the layout of an array of nodes.

TM

Abstract Treemap object.

Implemented By

TM.Squarified, TM.Strip and TM.SliceAndDice.

Description

Implements layout and configuration options inherited by TM.Squarified, TM.Strip and TM.SliceAndDice.

All Treemap constructors take the same configuration object as parameter.

Two special data keys are read from the JSON tree structure loaded by Loader.loadJSON to calculate node’s color and dimensions.  These properties are $area (for nodes dimensions) and $color.  Both of these properties are floats.

This means that the tree structure defined in Loader.loadJSON should now look more like this

var json = {
    "id": "aUniqueIdentifier",
    "name": "usually a nodes name",
    "data": {
        "$area": 33, //some float value
        "$color": 36, //-optional- some float value
        "some key": "some value",
        "some other key": "some other value"
     },
    "children": [ 'other nodes or empty' ]
};

If you want to know more about JSON tree structures and the data property please read Loader.loadJSON.

Configuration

General

  • rootId The id of the div container where the Treemap will be injected.  Default’s ‘infovis’.
  • orientation For TM.Strip and TM.SliceAndDice only.  The layout algorithm orientation.  Possible values are ‘h’ or ‘v’.
  • levelsToShow Max depth of the plotted tree.  Useful when using the request method.
  • addLeftClickHandler Add a left click event handler to zoom in the Treemap view when clicking a node.  Default’s false.
  • addRightClickHandler Add a right click event handler to zoom out the Treemap view.  Default’s false.
  • selectPathOnHover If setted to true all nodes contained in the path between the hovered node and the root node will have an in-path CSS class.  Default’s false.

Nodes

There are two kinds of Treemap nodes.

Inner nodes are nodes having children, like Pearl Jam.

These nodes are represented by three div elements.  A content element, a head element (where the title goes) and a body element, where the children are laid out.

<div class="content">
  <div class="head">Pearl Jam</div>
  <div class="body">...other nodes here...</div>
</div>

Leaves are optionally colored nodes laying at the “bottom” of the tree.  For example, Yield, Vs. and Riot Act are leaves.

These nodes are represented by two div elements.  A content element and a wrapped leaf element

<div class="content">
  <div class="leaf">Yield</div>
</div>

There are some configuration properties regarding Treemap nodes

  • titleHeight The height of the title (head) div container.  Default’s 13.
  • offset The separation offset between the content div element and its contained div(s).  Default’s 4.

Color

Color is an object containing as properties

  • allow If true, the algorithm will check for the JSON node data $color property to add some color to the Treemap leaves.  This color is calculated by interpolating a node’s $color value range with a real RGB color range.  By specifying min|maxValues for the $color property and min|maxColorValues for the RGB counterparts, the visualization is able to interpolate color values and assign a proper color to the leaf node.  Default’s false.
  • minValue The minimum value expected for the $color value property.  Used for interpolating.  Default’s -100.
  • maxValue The maximum value expected for the $color value property.  Used for interpolating.  Default’s 100.
  • minColorValue A three-element RGB array defining the color to be assigned to the $color having minValue as value.  Default’s [255, 0, 50].
  • maxColorValue A three-element RGB array defining the color to be assigned to the $color having maxValue as value.  Default’s [0, 255, 50].

Tips

Tips is an object containing as properties

  • allow If true, a tooltip will be shown when a node is hovered.  The tooltip is a div DOM element having “tip” as CSS class.  Default’s false.
  • offsetX An offset added to the current tooltip x-position (which is the same as the current mouse position).  Default’s 20.
  • offsetY An offset added to the current tooltip y-position (which is the same as the current mouse position).  Default’s 20.
  • onShow(tooltip, node, isLeaf, domElement) Implement this method to change the HTML content of the tooltip when hovering a node.

Parameters

tooltipThe tooltip div element.
nodeThe corresponding JSON tree node (See also <Loader.loadJSON>).
isLeafWhether is a leaf or inner node.
domElementThe current hovered DOM element.

Controller options

You can also implement controller functions inside the configuration object.  These functions are

  • onBeforeCompute(node) This method is called right before performing all computation and animations to the JIT visualization.
  • onAfterCompute() This method is triggered right after all animations or computations for the JIT visualizations ended.
  • onCreateElement(content, node, isLeaf, elem1, elem2) This method is called on each newly created node.

Parameters

contentThe div wrapper element with content className.
nodeThe corresponding JSON tree node (See also <Loader.loadJSON>).
isLeafWhether is a leaf or inner node.  If the node’s an inner tree node, elem1 and elem2 will become the head and body div elements respectively.  If the node’s a leaf, then elem1 will become the div leaf element.
  • onDestroyElement(content, node, isLeaf, elem1, elem2) This method is called before collecting each node.  Takes the same parameters as onCreateElement.
  • request(nodeId, level, onComplete) This method is used for buffering information into the visualization.  When clicking on an empty node, the visualization will make a request for this node’s subtrees, specifying a given level for this subtree (defined by levelsToShow).  Once the request is completed, the onComplete object should be called with the given result.

See also TM.Squarified, TM.SliceAndDice and TM.Strip.

Summary
Functions
eachTraverses head and leaf nodes applying a given function
createBoxConstructs the proper DOM layout from a json node.
plotRenders the Treemap.
headBoxCreates the head div dom element that usually contains the name of a parent JSON tree node.
bodyBoxCreates the body div dom element that usually contains a subtree dom element layout.
contentBoxCreates the content div dom element that usually contains a leaf div dom element or head and body div dom elements.
leafBoxCreates the leaf div dom element that usually contains nothing else.
setColorCalculates an hexa color string based on the $color data node property.
enterSets the elem parameter as root and performs the layout.
onLeftClickSets the elem parameter as root and performs the layout.
outSets the parent node of the currently shown subtree as root and performs the layout.
onRightClickSets the parent node of the currently shown subtree as root and performs the layout.
viewSets the root of the treemap to the specified node id and performs the layout.
resetPathSets an ‘in-path’ className for leaf and head elements which belong to the path between the given tree node and the visualization’s root node.
initializeElementsTraverses the DOM tree applying the onCreateElement method.
destroyElementsTraverses the tree applying the onDestroyElement method.
emptyEmpties the Treemap container (trying also to garbage collect things).
loadTreeLoads the subtree specified by id and plots it on the layout container.

Functions

each

each: function(f)

Traverses head and leaf nodes applying a given function

Parameters

fA function that takes as parameters the same as the onCreateElement and onDestroyElement methods described in TM.

createBox

createBox: function(json,
coord,
html)

Constructs the proper DOM layout from a json node.

If the node’s an inner node, this method calls TM.contentBox, TM.bodyBox and TM.leafBox to create the following HTML structure

<div class="content">
  <div class="head">[Node name]</div>
  <div class="body">[Node's children]</div>
</div>

If the node’s a leaf node, it creates the following structure by calling TM.contentBox, TM.leafBox

<div class="content">
  <div class="leaf">[Node name]</div>
</div>

Parameters

jsonA JSON subtree.  See also Loader.loadJSON.
coordA coordinates object specifying width, height, left and top style properties.
htmlhtml to inject into the body element if the node is an inner Tree node.

Returns

The HTML structure described above.

See also

TM, TM.contentBox, TM.bodyBox, TM.headBox, TM.leafBox.

plot

plot: function(json)

Renders the Treemap.

Parameters

jsonA JSON tree structure preprocessed by some Treemap layout algorithm.

Returns

The HTML to inject to the main visualization container.

See also

TM.createBox.

headBox

headBox: function(json,
coord)

Creates the head div dom element that usually contains the name of a parent JSON tree node.

Parameters

jsonA JSON subtree.  See also Loader.loadJSON.
coordwidth and height base coordinate object.

Returns

A new head div dom element that has head as class name.

See also

TM.createBox.

bodyBox

bodyBox: function(html,
coord)

Creates the body div dom element that usually contains a subtree dom element layout.

Parameters

htmlhtml that should be contained in the body html.
coordwidth and height base coordinate object.

Returns

A new body div dom element that has body as class name.

See also

TM.createBox.

contentBox

contentBox: function(json,
coord,
html)

Creates the content div dom element that usually contains a leaf div dom element or head and body div dom elements.

Parameters

jsonA JSON node.  See also Loader.loadJSON.
coordAn object containing width, height, left and top coordinates.
htmlinput html wrapped by this tag.

Returns

A new content div dom element that has content as class name.

See also

TM.createBox.

leafBox

leafBox: function(json,
coord)

Creates the leaf div dom element that usually contains nothing else.

Parameters

jsonA JSON subtree.  See also Loader.loadJSON.
coordbase with and height coordinate object.

Returns

A new leaf div dom element having leaf as class name.

See also

TM.createBox.

setColor

setColor: function(json)

Calculates an hexa color string based on the $color data node property.

This method is called by TM.leafBox to assign an hexadecimal color to each leaf node.

This color is calculated by making a linear interpolation between $color max and min values and RGB max and min values so that

hex = (maxColorValue - minColorValue) / (maxValue - minValue) * (x - minValue) + minColorValue

where x range is [minValue, maxValue] and

  • minValue
  • maxValue
  • minColorValue
  • maxColorValue

are defined in the TM configuration object.

This method is called by TM.leafBox iif Color.allow is setted to true.

Sometimes linear interpolation for coloring is just not enough.  In that case you can re-implement this method so that it fits your coloring needs.

Some people might find useful to implement their own coloring interpolation method and to assign the resulting hex string to the $color property.  In that case we could re-implement the TM.setColor method like this

//TM.Strip, TM.SliceAndDice also work
TM.Squarified.implement({
  'setColor': function(json) {
    return json.data.$color;
  }
});

So that it returns the previously assigned hex string.

Parameters

jsonA JSON tree node.

Returns

A String that represents a color in hex value.

enter

enter: function(elem)

Sets the elem parameter as root and performs the layout.

Parameters

elemA JSON Tree node.  See also Loader.loadJSON.

onLeftClick

onLeftClick: function(elem)

Sets the elem parameter as root and performs the layout.  This method is called when addLeftClickHandler is true and a node is left-clicked.  You can override this method to add some custom behavior when the node is left clicked though.

An Example for overriding this method could be

//TM.Strip or TM.SliceAndDice also work
TM.Squarified.implement({
    'onLeftClick': function(elem) {
        //some custom code...
    }
});

Parameters

elemA JSON Tree node.  See also Loader.loadJSON.

See also

TM.enter

out

out: function()

Sets the parent node of the currently shown subtree as root and performs the layout.

onRightClick

onRightClick: function()

Sets the parent node of the currently shown subtree as root and performs the layout.  This method is called when addRightClickHandler is true and a node is right-clicked.  You can override this method to add some custom behavior when the node is right-clicked though.

An Example for overriding this method could be

//TM.Strip or TM.SliceAndDice also work
TM.Squarified.implement({
    'onRightClick': function() {
        //some custom code...
    }
});

See also

TM.out

view

view: function(id)

Sets the root of the treemap to the specified node id and performs the layout.

Parameters

idA node identifier

resetPath

resetPath: function(tree)

Sets an ‘in-path’ className for leaf and head elements which belong to the path between the given tree node and the visualization’s root node.

Parameters

treeA JSON tree node.  See also Loader.loadJSON.

initializeElements

initializeElements: function()

Traverses the DOM tree applying the onCreateElement method.

The onCreateElement controller method should attach events and add some behavior to the DOM element node created.  By default, the Treemap wont add any event to its elements.

destroyElements

destroyElements: function()

Traverses the tree applying the onDestroyElement method.

The onDestroyElement controller method should detach events and garbage collect the element.  By default, the Treemap adds some garbage collect facilities for IE.

empty

empty: function()

Empties the Treemap container (trying also to garbage collect things).

loadTree

loadTree: function(id)

Loads the subtree specified by id and plots it on the layout container.

Parameters

idA subtree id.

TM.SliceAndDice

A JavaScript implementation of the Slice and Dice Treemap algorithm.

The TM.SliceAndDice constructor takes an optional configuration object described in TM.

This visualization (as all other Treemap visualizations) is fed with JSON Tree structures.

The $area node data key is required for calculating rectangles dimensions.

The $color node data key is required if Color allow is true and is used for calculating leaves colors.

Extends

TM

Parameters

configConfiguration defined in TM.

Example

Here’s a way of instanciating the TM.SliceAndDice will all its optional configuration features

var tm = new TM.SliceAndDice({
    orientation: "h",
  titleHeight: 13,
  rootId: 'infovis',
  offset:4,
  levelsToShow: 3,
      addLeftClickHandler: false,
      addRightClickHandler: false,
      selectPathOnHover: false,

  Color: {
    allow: false,
    minValue: -100,
    maxValue: 100,
    minColorValue: [255, 0, 50],
    maxColorValue: [0, 255, 50]
        },

        Tips: {
          allow: false,
          offsetX; 20,
          offsetY: 20,
          onShow: function(tooltip, node, isLeaf, domElement) {}
        },

        onBeforeCompute:  function(node) {
          //Some stuff on before compute...
        },
        onAfterCompute:   function() {
          //Some stuff on after compute...
        },
        onCreateElement:  function(content, node, isLeaf, head, body) {
          //Some stuff onCreateElement
        },
        onDestroyElement: function(content, node, isLeaf, head, body) {
          //Some stuff onDestroyElement
        },
      request:          false
  });
tm.loadJSON(json);
Summary
Functions
loadJSONLoads the specified JSON tree and lays it on the main container.
computeCalled by loadJSON to calculate recursively all node positions and lay out the tree.

Functions

loadJSON

loadJSON: function (json)

Loads the specified JSON tree and lays it on the main container.

Parameters

jsonA JSON Tree.  See also Loader.loadJSON.

compute

compute: function(par,
json,
orientation)

Called by loadJSON to calculate recursively all node positions and lay out the tree.

Parameters

parThe parent node of the json subtree.
jsonA JSON subtree.  See also Loader.loadJSON.
orientationThe current orientation.  This value is switched recursively.

TM.Area

Abstract Treemap class containing methods that are common to aspect ratio related algorithms such as TM.Squarified and TM.Strip.

Implemented by

TM.Squarified, TM.Strip

Summary
Functions
loadJSONLoads the specified JSON tree and lays it on the main container.
computeDimComputes dimensions and positions of a group of nodes according to a custom layout row condition.
worstAspectRatioCalculates the worst aspect ratio of a group of rectangles.
avgAspectRatioCalculates the average aspect ratio of a group of rectangles.

Functions

loadJSON

loadJSON: function (json)

Loads the specified JSON tree and lays it on the main container.

Parameters

jsonA JSON tree.  See also Loader.loadJSON.

computeDim

computeDim: function(tail,
initElem,
w,
coord,
comp)

Computes dimensions and positions of a group of nodes according to a custom layout row condition.

Parameters

tailAn array of nodes.
initElemAn array of nodes (containing the initial node to be laid).
wA fixed dimension where nodes will be layed out.
coordA coordinates object specifying width, height, left and top style properties.
compA custom comparison function

worstAspectRatio

worstAspectRatio: function(ch,
w)

Calculates the worst aspect ratio of a group of rectangles.

See also

http://en.wikipedia.org/wiki/Aspect_ratio

Parameters

chAn array of nodes.
wThe fixed dimension where rectangles are being laid out.

Returns

The worst aspect ratio.

avgAspectRatio

avgAspectRatio: function(ch,
w)

Calculates the average aspect ratio of a group of rectangles.

See also

http://en.wikipedia.org/wiki/Aspect_ratio

Parameters

chAn array of nodes.
wThe fixed dimension where rectangles are being laid out.

Returns

The average aspect ratio.

TM.Squarified

A JavaScript implementation of the Squarified Treemap algorithm.

The TM.Squarified constructor takes an optional configuration object described in TM.

This visualization (as all other Treemap visualizations) is fed with JSON Tree structures.

The $area node data key is required for calculating rectangles dimensions.

The $color node data key is required if Color allow is true and is used for calculating leaves colors.

Extends

TM and TM.Area

Parameters

configConfiguration defined in TM.

Example

Here’s a way of instanciating the TM.Squarified will all its optional configuration features

var tm = new TM.Squarified({
  titleHeight: 13,
  rootId: 'infovis',
  offset:4,
  levelsToShow: 3,
  addLeftClickHandler: false,
  addRightClickHandler: false,
  selectPathOnHover: false,

  Color: {
    allow: false,
    minValue: -100,
    maxValue: 100,
    minColorValue: [255, 0, 50],
    maxColorValue: [0, 255, 50]
  },

  Tips: {
    allow: false,
    offsetX: 20,
    offsetY: 20,
    onShow: function(tooltip, node, isLeaf, domElement) {}
  },

    onBeforeCompute:  function(node) {
      //Some stuff on before compute...
    },
    onAfterCompute:   function() {
      //Some stuff on after compute...
    },
    onCreateElement:  function(content, node, isLeaf, head, body) {
      //Some stuff onCreateElement
    },
    onDestroyElement: function(content, node, isLeaf, head, body) {
      //Some stuff onDestroyElement
    },
    request:          false
  });

  tm.loadJSON(json);
Summary
Functions
computeCalled by loadJSON to calculate recursively all node positions and lay out the tree.
processChildrenLayoutComputes children real areas and other useful parameters for performing the Squarified algorithm.
squarifyPerforms an heuristic method to calculate div elements sizes in order to have a good aspect ratio.
layoutRowPerforms the layout of an array of nodes.

Functions

compute

compute: function(json,
coord)

Called by loadJSON to calculate recursively all node positions and lay out the tree.

Parameters

jsonA JSON tree.  See also Loader.loadJSON.
coordA coordinates object specifying width, height, left and top style properties.

processChildrenLayout

processChildrenLayout: function(par,
ch,
coord)

Computes children real areas and other useful parameters for performing the Squarified algorithm.

Parameters

parThe parent node of the json subtree.
chAn Array of nodes
coordA coordinates object specifying width, height, left and top style properties.

squarify

squarify: function(tail,
initElem,
w,
coord)

Performs an heuristic method to calculate div elements sizes in order to have a good aspect ratio.

Parameters

tailAn array of nodes.
initElemAn array of nodes, containing the initial node to be laid out.
wA fixed dimension where nodes will be laid out.
coordA coordinates object specifying width, height, left and top style properties.

layoutRow

layoutRow: function(ch,
w,
coord)

Performs the layout of an array of nodes.

Parameters

chAn array of nodes.
wA fixed dimension where nodes will be laid out.
coordA coordinates object specifying width, height, left and top style properties.

TM.Strip

A JavaScript implementation of the Strip Treemap algorithm.

The TM.Strip constructor takes an optional configuration object described in TM.

This visualization (as all other Treemap visualizations) is fed with JSON Tree structures.

The $area node data key is required for calculating rectangles dimensions.

The $color node data key is required if Color allow is true and is used for calculating leaves colors.

Extends

TM and TM.Area

Parameters

configConfiguration defined in TM.

Example

Here’s a way of instanciating the TM.Strip will all its optional configuration features

var tm = new TM.Strip({
  titleHeight: 13,
    orientation: "h",
  rootId: 'infovis',
  offset:4,
  levelsToShow: 3,
      addLeftClickHandler: false,
      addRightClickHandler: false,
      selectPathOnHover: false,

  Color: {
    allow: false,
    minValue: -100,
    maxValue: 100,
    minColorValue: [255, 0, 50],
    maxColorValue: [0, 255, 50]
        },

        Tips: {
          allow: false,
          offsetX: 20,
          offsetY: 20,
          onShow: function(tooltip, node, isLeaf, domElement) {}
        },

        onBeforeCompute:  function(node) {
          //Some stuff on before compute...
        },
        onAfterCompute:   function() {
          //Some stuff on after compute...
        },
        onCreateElement:  function(content, node, isLeaf, head, body) {
          //Some stuff onCreateElement
        },
        onDestroyElement: function(content, node, isLeaf, head, body) {
          //Some stuff onDestroyElement
        },
      request:          false
  });
tm.loadJSON(json);
Summary
Functions
computeCalled by loadJSON to calculate recursively all node positions and lay out the tree.
processChildrenLayoutComputes children real areas and other useful parameters for performing the Strip algorithm.
stripifyPerforms an heuristic method to calculate div elements sizes in order to have a good compromise between aspect ratio and order.
layoutRowPerforms the layout of an array of nodes.

Functions

compute

compute: function(json,
coord)

Called by loadJSON to calculate recursively all node positions and lay out the tree.

Parameters

jsonA JSON subtree.  See also Loader.loadJSON.
coordA coordinates object specifying width, height, left and top style properties.

processChildrenLayout

processChildrenLayout: function(par,
ch,
coord)

Computes children real areas and other useful parameters for performing the Strip algorithm.

Parameters

parThe parent node of the json subtree.
chAn Array of nodes
coordA coordinates object specifying width, height, left and top style properties.

stripify

stripify: function(tail,
initElem,
w,
coord)

Performs an heuristic method to calculate div elements sizes in order to have a good compromise between aspect ratio and order.

Parameters

tailAn array of nodes.
initElemAn array of nodes.
wA fixed dimension where nodes will be layed out.
coordA coordinates object specifying width, height, left and top style properties.

layoutRow

layoutRow: function(ch,
w,
coord)

Performs the layout of an array of nodes.

Parameters

chAn array of nodes.
wA fixed dimension where nodes will be laid out.
coordA coordinates object specifying width, height, left and top style properties.
Abstract Treemap object.
each: function(f)
Traverses head and leaf nodes applying a given function
createBox: function(json,
coord,
html)
Constructs the proper DOM layout from a json node.
plot: function(json)
Renders the Treemap.
headBox: function(json,
coord)
Creates the head div dom element that usually contains the name of a parent JSON tree node.
bodyBox: function(html,
coord)
Creates the body div dom element that usually contains a subtree dom element layout.
contentBox: function(json,
coord,
html)
Creates the content div dom element that usually contains a leaf div dom element or head and body div dom elements.
leafBox: function(json,
coord)
Creates the leaf div dom element that usually contains nothing else.
setColor: function(json)
Calculates an hexa color string based on the $color data node property.
enter: function(elem)
Sets the elem parameter as root and performs the layout.
onLeftClick: function(elem)
Sets the elem parameter as root and performs the layout.
out: function()
Sets the parent node of the currently shown subtree as root and performs the layout.
onRightClick: function()
Sets the parent node of the currently shown subtree as root and performs the layout.
view: function(id)
Sets the root of the treemap to the specified node id and performs the layout.
resetPath: function(tree)
Sets an ‘in-path’ className for leaf and head elements which belong to the path between the given tree node and the visualization’s root node.
initializeElements: function()
Traverses the DOM tree applying the onCreateElement method.
destroyElements: function()
Traverses the tree applying the onDestroyElement method.
empty: function()
Empties the Treemap container (trying also to garbage collect things).
loadTree: function(id)
Loads the subtree specified by id and plots it on the layout container.
loadJSON: function (json)
Loads the specified JSON tree and lays it on the main container.
compute: function(par,
json,
orientation)
Called by loadJSON to calculate recursively all node positions and lay out the tree.
A JavaScript implementation of the Squarified Treemap algorithm.
A JavaScript implementation of the Strip Treemap algorithm.
loadJSON: function (json)
Loads the specified JSON tree and lays it on the main container.
computeDim: function(tail,
initElem,
w,
coord,
comp)
Computes dimensions and positions of a group of nodes according to a custom layout row condition.
worstAspectRatio: function(ch,
w)
Calculates the worst aspect ratio of a group of rectangles.
avgAspectRatio: function(ch,
w)
Calculates the average aspect ratio of a group of rectangles.
compute: function(json,
coord)
Called by loadJSON to calculate recursively all node positions and lay out the tree.
processChildrenLayout: function(par,
ch,
coord)
Computes children real areas and other useful parameters for performing the Squarified algorithm.
squarify: function(tail,
initElem,
w,
coord)
Performs an heuristic method to calculate div elements sizes in order to have a good aspect ratio.
layoutRow: function(ch,
w,
coord)
Performs the layout of an array of nodes.
compute: function(json,
coord)
Called by loadJSON to calculate recursively all node positions and lay out the tree.
processChildrenLayout: function(par,
ch,
coord)
Computes children real areas and other useful parameters for performing the Strip algorithm.
stripify: function(tail,
initElem,
w,
coord)
Performs an heuristic method to calculate div elements sizes in order to have a good compromise between aspect ratio and order.
layoutRow: function(ch,
w,
coord)
Performs the layout of an array of nodes.
A JavaScript implementation of the Slice and Dice Treemap algorithm.
loadJSON: function(json,
i)
Loads a JSON structure to the visualization.
Abstract Treemap class containing methods that are common to aspect ratio related algorithms such as TM.Squarified and TM.Strip.
Close