Class Index | File Index

Classes


Class pv.Scale.linear


Extends pv.Scale.quantitative.
Represents a linear scale; a function that performs a linear transformation. Most commonly, a linear scale represents a 1-dimensional linear transformation from a numeric domain of input data [d0, d1] to a numeric range of pixels [r0, r1]. The equation for such a scale is:

f(x) = (x - d0) / (d1 - d0) * (r1 - r0) + r0
For example, a linear scale from the domain [0, 100] to range [0, 640]:
f(x) = (x - 0) / (100 - 0) * (640 - 0) + 0
f(x) = x / 100 * 640
f(x) = x * 6.4
Thus, saying
    .height(function(d) d * 6.4)
is identical to
    .height(pv.Scale.linear(0, 100).range(0, 640))
Note that the scale is itself a function, and thus can be used as a property directly, assuming that the data associated with a mark is a number. While this is convenient for single-use scales, frequently it is desirable to define scales globally:
var y = pv.Scale.linear(0, 100).range(0, 640);
The y scale can now be equivalently referenced within a property:
    .height(function(d) y(d))
Alternatively, if the data are not simple numbers, the appropriate value can be passed to the y scale (e.g., d.foo). The #by method similarly allows the data to be mapped to a numeric value before performing the linear transformation.
Defined in: LinearScale.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Returns a linear scale for the specified domain.
Methods borrowed from class pv.Scale.quantitative:
by, domain, invert, nice, range, tickFormat, ticks
Class Detail
pv.Scale.linear()
Returns a linear scale for the specified domain. The arguments to this constructor are optional, and equivalent to calling #domain. The default domain and range are [0,1].
Parameters:
{number...} domain...
optional domain values.

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