Class Index | File Index

Classes


Class pv.Geo.scale

Represents a geographic scale; a mapping between latitude-longitude coordinates and screen pixel coordinates. By default, the domain is inferred from the geographic coordinates, so that the domain fills the output range.

Note that geographic scales are two-dimensional transformations, rather than the one-dimensional bidrectional mapping typical of other scales. Rather than mapping (for example) between a numeric domain and a numeric range, geographic scales map between two coordinate objects: {@link pv.Geo.LatLng} and pv.Vector.
Defined in: GeoScale.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Returns a geographic scale.
Method Summary
Method Attributes Method Name and Description
 
by(f)
Returns a view of this scale by the specified accessor function f.
 
Sets or gets the input domain.
 
invert(y)
Inverts the specified value in the output range, returning the corresponding value in the input domain.
 
Sets or gets the output range.
Class Detail
pv.Geo.scale(p)
Returns a geographic scale. The arguments to this constructor are optional, and equivalent to calling #projection.
Parameters:
{pv.Geo.Projection} p Optional
optional projection.
See:
pv.Geo.scale#ticks
Method Detail
{pv.Geo.scale} by(f)
Returns a view of this scale by the specified accessor function f. Given a scale g, g.by(function(d) d.foo) is equivalent to function(d) g(d.foo). This method should be used judiciously; it is typically more clear to invoke the scale directly, passing in the value to be scaled.
Parameters:
{function} f
an accessor function.
Returns:
{pv.Geo.scale} a view of this scale by the specified accessor function.

{pv.Geo.scale} domain()
Sets or gets the input domain. Note that unlike quantitative scales, the domain cannot be reduced to a simple rectangle (i.e., minimum and maximum values for latitude and longitude). Instead, the domain values must be projected to normalized space, effectively finding the domain in normalized space rather than in terms of latitude and longitude. Thus, changing the projection requires recomputing the normalized domain.

This method can be invoked several ways:

1. domain(values...)

Specifying the domain as a series of pv.Geo.LatLngs is the most explicit and recommended approach. However, if the domain values are derived from data, you may find the second method more appropriate.

2. domain(array, f)

Rather than enumerating the domain explicitly, you can specify a single argument of an array. In addition, you can specify an optional accessor function to extract the domain values (as pv.Geo.LatLngs) from the array. If the specified array has fewer than two elements, this scale will default to the full normalized domain.

2. domain()

Invoking the domain method with no arguments returns the current domain as an array.

Parameters:
{...} domain...
domain values.
Returns:
{pv.Geo.scale} this, or the current domain.

{number} invert(y)
Inverts the specified value in the output range, returning the corresponding value in the input domain. This is frequently used to convert the mouse location (see pv.Mark#mouse) to a value in the input domain. Inversion is only supported for numeric ranges, and not colors.

Note that this method does not do any rounding or bounds checking. If the input domain is discrete (e.g., an array index), the returned value should be rounded. If the specified y value is outside the range, the returned value may be equivalently outside the input domain.

Parameters:
{number} y
a value in the output range (a pixel location).
Returns:
{number} a value in the input domain.

{pv.Geo.scale} range()
Sets or gets the output range. This method can be invoked several ways:

1. range(min, max)

If two objects are specified, the arguments should be pv.Vectors which specify the minimum and maximum values of the x- and y-coordinates explicitly.

2. range(width, height)

If two numbers are specified, the arguments specify the maximum values of the x- and y-coordinates explicitly; the minimum values are implicitly zero.

3. range()

Invoking the range method with no arguments returns the current range as an array of two pv.Vectors: the minimum (top-left) and maximum (bottom-right) values.

Parameters:
{...} range...
range values.
Returns:
{pv.Geo.scale} this, or the current range.

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