Class Index | File Index

Classes


Class pv.Tree

Represents a tree operator for the specified array. The tree operator allows a hierarchical map to be constructed from an array; it is similar to the pv.Nest operator, except the hierarchy is derived dynamically from the array elements.

For example, given an array of size information for ActionScript classes:

{ name: "flare.flex.FlareVis", size: 4116 },
{ name: "flare.physics.DragForce", size: 1082 },
{ name: "flare.physics.GravityForce", size: 1336 }, ...
To facilitate visualization, it may be useful to nest the elements by their package hierarchy:
var tree = pv.tree(classes)
    .keys(function(d) d.name.split("."))
    .map();
The resulting tree is:
{ flare: {
    flex: {
      FlareVis: {
        name: "flare.flex.FlareVis",
        size: 4116 } },
    physics: {
      DragForce: {
        name: "flare.physics.DragForce",
        size: 1082 },
      GravityForce: {
        name: "flare.physics.GravityForce",
        size: 1336 } },
    ... } }
By specifying a value function,
var tree = pv.tree(classes)
    .keys(function(d) d.name.split("."))
    .value(function(d) d.size)
    .map();
we can further eliminate redundant data:
{ flare: {
    flex: {
      FlareVis: 4116 },
    physics: {
      DragForce: 1082,
      GravityForce: 1336 },
  ... } }
For visualizations with large data sets, performance improvements may be seen by storing the data in a tree format, and then flattening it into an array at runtime with pv.Flatten.
Defined in: Tree.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
pv.Tree(array)
Constructs a tree operator for the specified array.
Method Summary
Method Attributes Method Name and Description
 
keys(k)
Assigns a keys function to this operator; required.
 
map()
Returns a hierarchical map of values.
 
value(k)
Assigns a value function to this operator; optional.
Class Detail
pv.Tree(array)
Constructs a tree operator for the specified array. This constructor should not be invoked directly; use pv.tree instead.
Parameters:
{array} array
an array from which to construct a tree.
Method Detail
{pv.Tree} keys(k)
Assigns a keys function to this operator; required. The keys function returns an array of strings for each element in the associated array; these keys determine how the elements are nested in the tree. The returned keys should be unique for each element in the array; otherwise, the behavior of this operator is undefined.
Parameters:
{function} k
the keys function.
Returns:
{pv.Tree} this.

map()
Returns a hierarchical map of values. The hierarchy is determined by the keys function; the values in the map are determined by the value function.
Returns:
a hierarchical map of values.

{pv.Tree} value(k)
Assigns a value function to this operator; optional. The value function specifies an optional transformation of the element in the array before it is inserted into the map. If no value function is specified, it is equivalent to using the identity function.
Parameters:
{function} k
the value function.
Returns:
{pv.Tree} this.

Documentation generated by JsDoc Toolkit 2.3.2 on Sun May 30 2010 18:10:25 GMT-0700 (PDT)