Class Index | File Index

Classes


Class pv.Layout.icicle

A tree layout in the form of an icicle. The first row corresponds to the root of the tree; subsequent rows correspond to each tier. Rows are subdivided into cells based on the size of nodes, per #size. Within a row, cells are sorted by size.

This tree layout is intended to be extended (see pv.Mark#extend) by a pv.Bar. The data property returns an array of nodes for use by other property functions. The following node attributes are supported:

To produce a default icicle layout, say:
.add(pv.Bar)
  .extend(pv.Layout.icicle(tree))
To customize the tree to highlight leaf nodes bigger than 10,000 (1E4), you might say:
.add(pv.Bar)
  .extend(pv.Layout.icicle(tree))
  .fillStyle(function(n) n.data > 1e4 ? "#ff0" : "#fff")
The format of the tree argument is any hierarchical object whose leaf nodes are numbers corresponding to their size. For an example, and information on how to convert tabular data into such a tree, see pv.Tree. If the leaf nodes are not numbers, a #size function can be specified to override how the tree is interpreted. This size function can also be used to transform the data.

By default, the icicle fills the full width and height of the parent panel. An optional root key can be specified using #root for convenience.

Defined in: Icicle.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Returns a new icicle tree layout.
Method Summary
Method Attributes Method Name and Description
 
root(v)
Specifies the root key; optional.
 
size(f)
Specifies the sizing function.
Class Detail
pv.Layout.icicle(tree)

Returns a new icicle tree layout.

Parameters:
tree
a tree (an object) who leaf attributes have sizes.
Returns:
{pv.Layout.icicle} a tree layout.
Method Detail
{pv.Layout.icicle} root(v)

Specifies the root key; optional. The root key is prepended to the keys attribute for all generated nodes. This method is provided for convenience and does not affect layout.

Parameters:
{string} v
the root key.
Returns:
{pv.Layout.icicle} this.

{pv.Layout.icicle} size(f)

Specifies the sizing function. By default, the sizing function is Number. The sizing function is invoked for each node in the tree (passed to the constructor): the sizing function must return undefined or NaN for internal nodes, and a number for leaf nodes. The aggregate sizes of internal nodes will be automatically computed by the layout.

For example, if the tree data structure represents a file system, with files as leaf nodes, and each file has a bytes attribute, you can specify a size function as:

.size(function(d) d.bytes)
This function will return undefined for internal nodes (since these do not have a bytes attribute), and a number for leaf nodes.

Note that the built-in Math.sqrt and Math.log methods can also be used as sizing functions. These function similarly to Number, except perform a root and log scale, respectively.

Parameters:
{function} f
the new sizing function.
Returns:
{pv.Layout.icicle} this.

Documentation generated by JsDoc Toolkit 2.3.0 on Sat Sep 19 2009 10:26:36 GMT-0700 (PDT)