Class Index | File Index

Classes


Class pv.Layout.sunburst

A tree layout in the form of a sunburst. The center circle corresponds to the root of the tree; subsequent rings correspond to each tier. Rings are subdivided into wedges based on the size of nodes, per #size. Within a ring, wedges are sorted by size.

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

To produce a default sunburst layout, say:

.add(pv.Wedge)
  .extend(pv.Layout.sunburst(tree))
To only show nodes at a depth of two or greater, you might say:
.add(pv.Wedge)
  .extend(pv.Layout.sunburst(tree))
  .visible(function(n) n.depth > 1)
The format of the tree argument is a 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 sunburst fills the full width and height of the parent panel. An optional root key can be specified using #root for convenience.

Defined in: Sunburst.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Returns a new sunburst 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.sunburst(tree)

Returns a new sunburst tree layout.

Parameters:
tree
a tree (an object) who leaf attributes have sizes.
Returns:
{pv.Layout.sunburst} a tree layout.
Method Detail
{pv.Layout.sunburst} 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.sunburst} this.

{pv.Layout.sunburst} 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 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.sunburst} this.

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