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.
Constructor Attributes | Constructor Name and Description |
---|---|
pv.Geo.scale(p)
Returns a geographic scale.
|
Method Attributes | Method Name and Description |
---|---|
by(f)
Returns a view of this scale by the specified accessor function f.
|
|
domain()
Sets or gets the input domain.
|
|
invert(y)
Inverts the specified value in the output range, returning the
corresponding value in the input domain.
|
|
range()
Sets or gets the output range.
|
- Parameters:
- {pv.Geo.Projection} p Optional
- optional projection.
- See:
- pv.Geo.scale#ticks
- Parameters:
- {function} f
- an accessor function.
- Returns:
- {pv.Geo.scale} a view of this scale by the specified accessor function.
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.
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.
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.