# Class pv.Scale.log

Extends pv.Scale.quantitative.
Represents a log scale. Most commonly, a log scale represents a 1-dimensional log 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) = (log(x) - log(d0)) / (log(d1) - log(d0)) * (r1 - r0) + r0
where log(x) represents the zero-symmetric logarthim of x using the scale's associated base (default: 10, see pv.logSymmetric). For example, a log scale from the domain [1, 100] to range [0, 640]:
f(x) = (log(x) - log(1)) / (log(100) - log(1)) * (640 - 0) + 0
f(x) = log(x) / 2 * 640
f(x) = log(x) * 320
Thus, saying
.height(function(d) Math.log(d) * 138.974)
is equivalent to
.height(pv.Scale.log(1, 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.log(1, 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 log transformation.
Defined in: LogScale.js.

Class Summary
Constructor Attributes Constructor Name and Description

Returns a log scale for the specified domain.
Method Summary
Method Attributes Method Name and Description

base(v)
Sets or gets the logarithm base.

nice()
"Nices" this scale, extending the bounds of the input domain to evenly-rounded values.

Formats the specified tick value using the appropriate precision, assuming base 10.

Returns an array of evenly-spaced, suitably-rounded values in the input domain.
Methods borrowed from class pv.Scale.quantitative:
by, domain, invert, range
Class Detail
pv.Scale.log()
Returns a log scale for the specified domain. The arguments to this constructor are optional, and equivalent to calling #domain. The default domain is [1,10] and the default range is [0,1].
Parameters:
{number...} domain...
optional domain values.
Method Detail
base(v)
Sets or gets the logarithm base. Defaults to 10.
Parameters:
{number} v Optional
the new base.
Returns:
this, or the current base.

nice()
"Nices" this scale, extending the bounds of the input domain to evenly-rounded values. This method uses pv.logFloor and pv.logCeil. Nicing is useful if the domain is computed dynamically from data, and may be irregular. For example, given a domain of [0.20147987687960267, 0.996679553296417], a call to nice() might extend the domain to [0.1, 1].

This method must be invoked each time after setting the domain (and base).

Returns:
this.

{string} tickFormat(t)
Formats the specified tick value using the appropriate precision, assuming base 10.
Parameters:
{number} t
a tick value.
Returns:
{string} a formatted tick value.

{number[]} ticks()
Returns an array of evenly-spaced, suitably-rounded values in the input domain. These values are frequently used in conjunction with pv.Rule to display tick marks or grid lines.
Returns:
{number[]} an array input domain values to use as ticks.

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