Class Index | File Index

Classes


Namespace pv

The top-level Protovis namespace, pv.
Defined in: pv.js.

Namespace Summary
Constructor Attributes Constructor Name and Description
 
pv
The top-level Protovis namespace.
Field Summary
Field Attributes Field Name and Description
<static>  
pv.event
Stores the current event.
Method Summary
Method Attributes Method Name and Description
<static>  
pv.blend(arrays)
Given the specified array of arrays, concatenates the arrays into a single array.
<static>  
pv.child()
Returns this.childIndex.
<static>  
pv.color(format)
Returns the pv.Color for the specified color format string.
<static>  
pv.colors()
Returns a new categorical color encoding using the specified colors.
<static>  
pv.cross(a, b)
Given two arrays a and b, returns an array of all possible pairs of elements [ai, bj].
<static>  
pv.degrees(radians)
Returns the number of degrees corresponding to the specified radians.
<static>  
pv.deviation(array, f)
Returns an unbiased estimation of the standard deviation of a population, given the specified random sample.
<static>  
pv.dict(keys, f)
Returns a map constructed from the specified keys, using the function f to compute the value for each key.
<static>  
pv.dom(map)
Returns a pv.Dom operator for the given map.
<static>  
pv.entries(map)
Returns all of the entries (key-value pairs) of the specified object (a map).
<static>  
pv.flatten(map)
Returns a pv.Flatten operator for the specified map.
<static>  
pv.hsl(h, s, l, a)
Constructs a new HSL color with the specified values.
<static>  
pv.identity(x)
Returns the passed-in argument, x; the identity function.
<static>  
pv.index()
Returns this.index.
<static>  
pv.keys(map)
Returns all of the property names (keys) of the specified object (a map).
<static>  
pv.log(x, b)
Returns the logarithm with a given base value.
<static>  
pv.logAdjusted(x, b)
Computes a zero-symmetric logarithm, with adjustment to values between zero and the logarithm base.
<static>  
pv.logCeil(x, b)
Rounds an input value up according to its logarithm.
<static>  
pv.logFloor(x, b)
Rounds an input value down according to its logarithm.
<static>  
pv.logSymmetric(x, b)
Computes a zero-symmetric logarithm.
<static>  
pv.max(array, f)
Returns the maximum value of the specified array.
<static>  
pv.mean(array, f)
Returns the arithmetic mean, or average, of the specified array.
<static>  
pv.median(array, f)
Returns the median of the specified array.
<static>  
pv.min(array, f)
Returns the minimum value of the specified array of numbers.
<static>  
pv.naturalOrder(a, b)
The comparator function for natural order.
<static>  
pv.nest(array)
Returns a pv.Nest operator for the specified array.
<static>  
pv.nodes()
Given a flat array of values, returns a simple DOM with each value wrapped by a node that is a child of the root node.
<static>  
pv.normalize(array, f)
Returns a normalized copy of the specified array, such that the sum of the returned elements sum to one.
<static>  
pv.numerate(keys, f)
Returns a map from key to index for the specified keys array.
<static>  
pv.parent()
Returns this.parent.index.
<static>  
pv.permute(array, indexes, f)
Returns a permutation of the specified array, using the specified array of indexes.
<static>  
pv.radians(degrees)
Returns the number of radians corresponding to the specified degrees.
<static>  
pv.ramp(start, end)
Returns a linear color ramp from the specified start color to the specified end color.
<static>  
pv.random(start, stop, step)
Returns a random number in the range [start, stop) that is a multiple of step.
<static>  
pv.range(start, stop, step)
Returns an array of numbers, starting at start, incrementing by step, until stop is reached.
<static>  
pv.repeat(a, n)
Concatenates the specified array with itself n times.
<static>  
pv.reverseOrder(a, b)
The comparator function for reverse natural order.
<static>  
pv.rgb(r, g, b, a)
Constructs a new RGB color with the specified channel values.
<static>  
pv.search(array, value, f)
Searches the specified array of numbers for the specified value using the binary search algorithm.
<static>  
pv.simulation(particles)
Constructs a new empty simulation.
<static>  
pv.sum(array, f)
Returns the sum of the specified array.
<static>  
pv.transpose(arrays)
Given the specified array of arrays, transposes each element arrayij with arrayji.
<static>  
pv.tree(array)
Returns a pv.Tree operator for the specified array.
<static>  
pv.uniq(array, f)
Returns the unique elements in the specified array, in the order they appear.
<static>  
pv.values(map)
Returns all of the values (attribute values) of the specified object (a map).
<static>  
pv.variance(array, f)
Returns the unweighted variance of the specified array.
<static>  
pv.vector(x, y)
Returns a pv.Vector for the specified x and y coordinate.
Namespace Detail
pv
The top-level Protovis namespace. All public methods and fields should be registered on this object. Note that core Protovis source is surrounded by an anonymous function, so any other declared globals will not be visible outside of core methods. This also allows multiple versions of Protovis to coexist, since each version will see their own pv namespace.
Field Detail
<static> {Event} pv.event
Stores the current event. This field is only set within event handlers.
Method Detail
<static> {array} pv.blend(arrays)
Given the specified array of arrays, concatenates the arrays into a single array. If the individual arrays are explicitly known, an alternative to blend is to use JavaScript's concat method directly. These two equivalent expressions:return [1, 2, 3, "a", "b", "c"].
Defined in: Arrays.js.
Parameters:
{array[]} arrays
an array of arrays.
Returns:
{array} an array containing all the elements of each array in arrays.

<static> pv.child()
Returns this.childIndex. This method is provided for convenience for use with scales. For example, to color bars by their child index, say:
.fillStyle(pv.Colors.category10().by(pv.child))
This method is equivalent to function() this.childIndex, but more succinct.
See:
pv.Scale
pv.Mark#childIndex

<static> {pv.Color} pv.color(format)
Returns the pv.Color for the specified color format string. Colors may have an associated opacity, or alpha channel. Color formats are specified by CSS Color Modular Level 3, using either in RGB or HSL color space. For example:The SVG 1.0 color keywords names are also supported, such as "aliceblue" and "yellowgreen". The "transparent" keyword is supported for fully- transparent black.

If the format argument is already an instance of Color, the argument is returned with no further processing.
Defined in: Color.js.

Parameters:
{string} format
the color specification string, such as "#f00".
Returns:
{pv.Color} the corresponding Color.
See:
SVG color keywords
CSS3 color module

<static> {pv.Scale.ordinal} pv.colors()
Returns a new categorical color encoding using the specified colors. The arguments to this method are an array of colors; see pv.color. For example, to create a categorical color encoding using the species attribute:
pv.colors("red", "green", "blue").by(function(d) d.species)
The result of this expression can be used as a fill- or stroke-style property. This assumes that the data's species attribute is a string.
Defined in: Colors.js.
Parameters:
{string} colors...
categorical colors.
Returns:
{pv.Scale.ordinal} an ordinal color scale.
See:
pv.Scale.ordinal

<static> {array} pv.cross(a, b)
Given two arrays a and b, returns an array of all possible pairs of elements [ai, bj]. The outer loop is on array a, while the inner loop is on b, such that the order of returned elements is [a0, b0], [a0, b1], ... [a0, bm], [a1, b0], [a1, b1], ... [a1, bm], ... [an, bm]. If either array is empty, an empty array is returned.
Defined in: Arrays.js.
Parameters:
{array} a
an array.
{array} b
an array.
Returns:
{array} an array of pairs of elements in a and b.

<static> pv.degrees(radians)
Returns the number of degrees corresponding to the specified radians.
Defined in: Numbers.js.
Parameters:
radians

<static> {number} pv.deviation(array, f)
Returns an unbiased estimation of the standard deviation of a population, given the specified random sample. If the specified array is not an array of numbers, an optional accessor function f can be specified to map the elements to numbers. See #normalize for an example. Accessor functions can refer to this.index.
Defined in: Numbers.js.
Parameters:
{array} array
an array of objects, or numbers.
{function} f Optional
an optional accessor function.
Returns:
{number} the standard deviation of the specified array.

<static> pv.dict(keys, f)
Returns a map constructed from the specified keys, using the function f to compute the value for each key. The single argument to the value function is the key. The callback is invoked only for indexes of the array which have assigned values; it is not invoked for indexes which have been deleted or which have never been assigned values.

For example, this expression creates a map from strings to string length:

pv.dict(["one", "three", "seventeen"], function(s) s.length)
The returned value is {one: 3, three: 5, seventeen: 9}. Accessor functions can refer to this.index.
Defined in: Objects.js.
Parameters:
{array} keys
an array.
{function} f
a value function.
Returns:
a map from keys to values.

<static> {pv.Dom} pv.dom(map)
Returns a pv.Dom operator for the given map. This is a convenience factory method, equivalent to new pv.Dom(map). To apply the operator and retrieve the root node, call pv.Dom#root; to retrieve all nodes flattened, use pv.Dom#nodes.
Defined in: Dom.js.
Parameters:
map
a map from which to construct a DOM.
Returns:
{pv.Dom} a DOM operator for the specified map.
See:
pv.Dom

<static> {array} pv.entries(map)
Returns all of the entries (key-value pairs) of the specified object (a map). The order of the returned array is not defined. Each key-value pair is represented as an object with key and value attributes, e.g., {key: "foo", value: 42}.
Defined in: Objects.js.
Parameters:
map
an object.
Returns:
{array} an array of key-value pairs corresponding to the keys.

<static> {pv.Flatten} pv.flatten(map)
Returns a pv.Flatten operator for the specified map. This is a convenience factory method, equivalent to new pv.Flatten(map).
Defined in: Flatten.js.
Parameters:
map
a map to flatten.
Returns:
{pv.Flatten} a flatten operator for the specified map.
See:
pv.Flatten

<static> pv.hsl(h, s, l, a)
Constructs a new HSL color with the specified values.
Defined in: Color.js.
Parameters:
{number} h
the hue, an integer in [0, 360].
{number} s
the saturation, a float in [0, 1].
{number} l
the lightness, a float in [0, 1].
{number} a Optional
the opacity, a float in [0, 1].
Returns:
pv.Color.Hsl

<static> pv.identity(x)
Returns the passed-in argument, x; the identity function. This method is provided for convenience since it is used as the default behavior for a number of property functions.
Parameters:
x
a value.
Returns:
the value x.

<static> pv.index()
Returns this.index. This method is provided for convenience for use with scales. For example, to color bars by their index, say:
.fillStyle(pv.Colors.category10().by(pv.index))
This method is equivalent to function() this.index, but more succinct. Note that the index property is also supported for accessor functions with pv.max, pv.min and other array utility methods.
See:
pv.Scale
pv.Mark#index

<static> {string[]} pv.keys(map)
Returns all of the property names (keys) of the specified object (a map). The order of the returned array is not defined.
Defined in: Objects.js.
Parameters:
map
an object.
Returns:
{string[]} an array of strings corresponding to the keys.
See:
#entries

<static> {number} pv.log(x, b)
Returns the logarithm with a given base value.
Defined in: Numbers.js.
Parameters:
{number} x
the number for which to compute the logarithm.
{number} b
the base of the logarithm.
Returns:
{number} the logarithm value.

<static> {number} pv.logAdjusted(x, b)
Computes a zero-symmetric logarithm, with adjustment to values between zero and the logarithm base. This adjustment introduces distortion for values less than the base number, but enables simultaneous plotting of log-transformed data involving both positive and negative numbers.
Defined in: Numbers.js.
Parameters:
{number} x
the number for which to compute the logarithm.
{number} b
the base of the logarithm.
Returns:
{number} the adjusted, symmetric log value.

<static> {number} pv.logCeil(x, b)
Rounds an input value up according to its logarithm. The method takes the ceiling of the logarithm of the value and then uses the resulting value as an exponent for the base value.
Defined in: Numbers.js.
Parameters:
{number} x
the number for which to compute the logarithm ceiling.
{number} b
the base of the logarithm.
Returns:
{number} the rounded-by-logarithm value.

<static> {number} pv.logFloor(x, b)
Rounds an input value down according to its logarithm. The method takes the floor of the logarithm of the value and then uses the resulting value as an exponent for the base value.
Defined in: Numbers.js.
Parameters:
{number} x
the number for which to compute the logarithm floor.
{number} b
the base of the logarithm.
Returns:
{number} the rounded-by-logarithm value.

<static> {number} pv.logSymmetric(x, b)
Computes a zero-symmetric logarithm. Computes the logarithm of the absolute value of the input, and determines the sign of the output according to the sign of the input value.
Defined in: Numbers.js.
Parameters:
{number} x
the number for which to compute the logarithm.
{number} b
the base of the logarithm.
Returns:
{number} the symmetric log value.

<static> {number} pv.max(array, f)
Returns the maximum value of the specified array. If the specified array is not an array of numbers, an optional accessor function f can be specified to map the elements to numbers. See #normalize for an example. Accessor functions can refer to this.index.
Defined in: Numbers.js.
Parameters:
{array} array
an array of objects, or numbers.
{function} f Optional
an optional accessor function.
Returns:
{number} the maximum value of the specified array.

<static> {number} pv.mean(array, f)
Returns the arithmetic mean, or average, of the specified array. If the specified array is not an array of numbers, an optional accessor function f can be specified to map the elements to numbers. See #normalize for an example. Accessor functions can refer to this.index.
Defined in: Numbers.js.
Parameters:
{array} array
an array of objects, or numbers.
{function} f Optional
an optional accessor function.
Returns:
{number} the mean of the specified array.

<static> {number} pv.median(array, f)
Returns the median of the specified array. If the specified array is not an array of numbers, an optional accessor function f can be specified to map the elements to numbers. See #normalize for an example. Accessor functions can refer to this.index.
Defined in: Numbers.js.
Parameters:
{array} array
an array of objects, or numbers.
{function} f Optional
an optional accessor function.
Returns:
{number} the median of the specified array.

<static> {number} pv.min(array, f)
Returns the minimum value of the specified array of numbers. If the specified array is not an array of numbers, an optional accessor function f can be specified to map the elements to numbers. See #normalize for an example. Accessor functions can refer to this.index.
Defined in: Numbers.js.
Parameters:
{array} array
an array of objects, or numbers.
{function} f Optional
an optional accessor function.
Returns:
{number} the minimum value of the specified array.

<static> {number} pv.naturalOrder(a, b)
The comparator function for natural order. This can be used in conjunction with the built-in array sort method to sort elements by their natural order, ascending. Note that if no comparator function is specified to the built-in sort method, the default order is lexicographic, not natural!
Defined in: Arrays.js.
Parameters:
a
an element to compare.
b
an element to compare.
Returns:
{number} negative if a < b; positive if a > b; otherwise 0.
See:
Array.sort.

<static> {pv.Nest} pv.nest(array)
Returns a pv.Nest operator for the specified array. This is a convenience factory method, equivalent to new pv.Nest(array).
Defined in: Nest.js.
Parameters:
{array} array
an array of elements to nest.
Returns:
{pv.Nest} a nest operator for the specified array.
See:
pv.Nest

<static> {array} pv.nodes()
Given a flat array of values, returns a simple DOM with each value wrapped by a node that is a child of the root node.
Defined in: Dom.js.
Parameters:
{array} values.
Returns:
{array} nodes.

<static> {number[]} pv.normalize(array, f)
Returns a normalized copy of the specified array, such that the sum of the returned elements sum to one. If the specified array is not an array of numbers, an optional accessor function f can be specified to map the elements to numbers. For example, if array is an array of objects, and each object has a numeric property "foo", the expression
pv.normalize(array, function(d) d.foo)
returns a normalized array on the "foo" property. If an accessor function is not specified, the identity function is used. Accessor functions can refer to this.index.
Defined in: Arrays.js.
Parameters:
{array} array
an array of objects, or numbers.
{function} f Optional
an optional accessor function.
Returns:
{number[]} an array of numbers that sums to one.

<static> pv.numerate(keys, f)
Returns a map from key to index for the specified keys array. For example,
pv.numerate(["a", "b", "c"])
returns {a: 0, b: 1, c: 2}. Note that since JavaScript maps only support string keys, keys must contain strings, or other values that naturally map to distinct string values. Alternatively, an optional accessor function f can be specified to compute the string key for the given element. Accessor functions can refer to this.index.
Defined in: Arrays.js.
Parameters:
{array} keys
an array, usually of string keys.
{function} f Optional
an optional key function.
Returns:
a map from key to index.

<static> pv.parent()
Returns this.parent.index. This method is provided for convenience for use with scales. This method is provided for convenience for use with scales. For example, to color bars by their parent index, say:
.fillStyle(pv.Colors.category10().by(pv.parent))
Tthis method is equivalent to function() this.parent.index, but more succinct.
See:
pv.Scale
pv.Mark#index

<static> {array} pv.permute(array, indexes, f)
Returns a permutation of the specified array, using the specified array of indexes. The returned array contains the corresponding element in array for each index in indexes, in order. For example,
pv.permute(["a", "b", "c"], [1, 2, 0])
returns ["b", "c", "a"]. It is acceptable for the array of indexes to be a different length from the array of elements, and for indexes to be duplicated or omitted. The optional accessor function f can be used to perform a simultaneous mapping of the array elements. Accessor functions can refer to this.index.
Defined in: Arrays.js.
Parameters:
{array} array
an array.
{number[]} indexes
an array of indexes into array.
{function} f Optional
an optional accessor function.
Returns:
{array} an array of elements from array; a permutation.

<static> pv.radians(degrees)
Returns the number of radians corresponding to the specified degrees.
Defined in: Numbers.js.
Parameters:
degrees

<static> {Function} pv.ramp(start, end)
Returns a linear color ramp from the specified start color to the specified end color. The color arguments may be specified either as strings or as pv.Colors. This is equivalent to:
    pv.Scale.linear().domain(0, 1).range(...)

Defined in: Ramp.js.
Parameters:
{string} start
the start color; may be a pv.Color.
{string} end
the end color; may be a pv.Color.
Returns:
{Function} a color ramp from start to end.
See:
pv.Scale.linear

<static> {number} pv.random(start, stop, step)
Returns a random number in the range [start, stop) that is a multiple of step. More specifically, the returned number is of the form start + n * step, where n is a nonnegative integer. If step is not specified, it defaults to 1, returning a random integer if start is also an integer.
Defined in: Numbers.js.
Parameters:
{number} start Optional
the start value value.
{number} stop
the stop value.
{number} step Optional
the step value.
Returns:
{number} a random number between start and stop.

<static> {number[]} pv.range(start, stop, step)
Returns an array of numbers, starting at start, incrementing by step, until stop is reached. The stop value is exclusive. If only a single argument is specified, this value is interpeted as the stop value, with the start value as zero. If only two arguments are specified, the step value is implied to be one.

The method is modeled after the built-in range method from Python. See the Python documentation for more details.
Defined in: Numbers.js.

Parameters:
{number} start Optional
the start value.
{number} stop
the stop value.
{number} step Optional
the step value.
Returns:
{number[]} an array of numbers.
See:
Python range

<static> {array} pv.repeat(a, n)
Concatenates the specified array with itself n times. For example, pv.repeat([1, 2]) returns [1, 2, 1, 2].
Defined in: Arrays.js.
Parameters:
{array} a
an array.
{number} n Optional
the number of times to repeat; defaults to two.
Returns:
{array} an array that repeats the specified array.

<static> {number} pv.reverseOrder(a, b)
The comparator function for reverse natural order. This can be used in conjunction with the built-in array sort method to sort elements by their natural order, descending. Note that if no comparator function is specified to the built-in sort method, the default order is lexicographic, not natural!
Defined in: Arrays.js.
Parameters:
a
an element to compare.
b
an element to compare.
Returns:
{number} negative if a < b; positive if a > b; otherwise 0.
See:
#naturalOrder

<static> pv.rgb(r, g, b, a)
Constructs a new RGB color with the specified channel values.
Defined in: Color.js.
Parameters:
{number} r
the red channel, an integer in [0,255].
{number} g
the green channel, an integer in [0,255].
{number} b
the blue channel, an integer in [0,255].
{number} a Optional
the alpha channel, a float in [0,1].
Returns:
pv.Color.Rgb

<static> pv.search(array, value, f)
Searches the specified array of numbers for the specified value using the binary search algorithm. The array must be sorted (as by the sort method) prior to making this call. If it is not sorted, the results are undefined. If the array contains multiple elements with the specified value, there is no guarantee which one will be found.

The insertion point is defined as the point at which the value would be inserted into the array: the index of the first element greater than the value, or array.length, if all elements in the array are less than the specified value. Note that this guarantees that the return value will be nonnegative if and only if the value is found.
Defined in: Arrays.js.

Parameters:
{number[]} array
the array to be searched.
{number} value
the value to be searched for.
{function} f Optional
an optional key function.
Returns:
the index of the search value, if it is contained in the array; otherwise, (-(insertion point) - 1).

<static> {pv.Simulation} pv.simulation(particles)
Constructs a new empty simulation.
Defined in: Simulation.js.
Parameters:
{array} particles
Returns:
{pv.Simulation} a new simulation for the specified particles.
See:
pv.Simulation

<static> {number} pv.sum(array, f)
Returns the sum of the specified array. If the specified array is not an array of numbers, an optional accessor function f can be specified to map the elements to numbers. See #normalize for an example. Accessor functions can refer to this.index.
Defined in: Numbers.js.
Parameters:
{array} array
an array of objects, or numbers.
{function} f Optional
an optional accessor function.
Returns:
{number} the sum of the specified array.

<static> {array[]} pv.transpose(arrays)
Given the specified array of arrays, transposes each element arrayij with arrayji. If the array has dimensions n×m, it will have dimensions m×n after this method returns. This method transposes the elements of the array in place, mutating the array, and returning a reference to the array.
Defined in: Arrays.js.
Parameters:
{array[]} arrays
an array of arrays.
Returns:
{array[]} the passed-in array, after transposing the elements.

<static> {pv.Tree} pv.tree(array)
Returns a pv.Tree operator for the specified array. This is a convenience factory method, equivalent to new pv.Tree(array).
Defined in: Tree.js.
Parameters:
{array} array
an array from which to construct a tree.
Returns:
{pv.Tree} a tree operator for the specified array.
See:
pv.Tree

<static> {array} pv.uniq(array, f)
Returns the unique elements in the specified array, in the order they appear. Note that since JavaScript maps only support string keys, array must contain strings, or other values that naturally map to distinct string values. Alternatively, an optional accessor function f can be specified to compute the string key for the given element. Accessor functions can refer to this.index.
Defined in: Arrays.js.
Parameters:
{array} array
an array, usually of string keys.
{function} f Optional
an optional key function.
Returns:
{array} the unique values.

<static> {array} pv.values(map)
Returns all of the values (attribute values) of the specified object (a map). The order of the returned array is not defined.
Defined in: Objects.js.
Parameters:
map
an object.
Returns:
{array} an array of objects corresponding to the values.
See:
#entries

<static> {number} pv.variance(array, f)
Returns the unweighted variance of the specified array. If the specified array is not an array of numbers, an optional accessor function f can be specified to map the elements to numbers. See #normalize for an example. Accessor functions can refer to this.index.
Defined in: Numbers.js.
Parameters:
{array} array
an array of objects, or numbers.
{function} f Optional
an optional accessor function.
Returns:
{number} the variance of the specified array.

<static> {pv.Vector} pv.vector(x, y)
Returns a pv.Vector for the specified x and y coordinate. This is a convenience factory method, equivalent to new pv.Vector(x, y).
Defined in: Vector.js.
Parameters:
{number} x
the x coordinate.
{number} y
the y coordinate.
Returns:
{pv.Vector} a vector for the specified coordinates.
See:
pv.Vector

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