Documentation ¶
Overview ¶
Package scale provides abstractions for scales that map from one domain to another and provide methods for indicating human-readable intervals in the input domain. The most common type of scale is a quantitative scale, such as a linear or log scale, which is captured by the Quantitative interface.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Linear ¶
type Linear struct {
// Min and Max specify the lower and upper bounds of the input
// range. The input range [Min, Max] will be linearly mapped
// to the output domain [0, 1].
Min, Max float64
// Base specifies a base for computing ticks. Ticks will be
// placed at powers of Base; that is at n*Base^l for n ∈ ℤ and
// some integer l. As a special case, a base of 0 alternates
// between ticks at n*10^l and ticks at 5n*10^l.
Base int
// If Clamp is true, the input is clamped to [Min, Max].
Clamp bool
}
type Log ¶
type Log struct {
// Min and Max specify the lower and upper bounds of the input
// range. The input range [Min, Max] will be mapped to the
// output domain [0, 1]. The range [Min, Max] must not include
// 0.
Min, Max float64
// Base specifies the base of the logarithm for computing
// ticks. Typically, ticks will be placed at Base^n for n ∈ ℤ.
Base int
// If Clamp is true, the input is clamped to [Min, Max].
Clamp bool
// contains filtered or unexported fields
}
type QQ ¶
type QQ struct {
Src, Dest Quantitative
}
A QQ maps from a source Quantitative scale to a destination Quantitative scale.
type Quantitative ¶
type Quantitative interface { // Map maps from a value x in the input range to [0, 1]. If x // is outside the input range and clamping is enabled, x will // first be clamped to the input range. Map(x float64) float64 // Unmap is the inverse of Map. That is, if x is in the input // range or clamping is disabled, x = Unmap(Map(x)). If // clamping is enabled and y is outside [0,1], the results are // undefined. Unmap(y float64) float64 // SetClamp sets the clamping mode of this scale. SetClamp(bool) // Ticks returns a set of at most n major ticks, plus minor // ticks. These ticks will have "nice" values within the input // range. Both arrays are sorted in ascending order and minor // includes ticks in major. Ticks(n int) (major, minor []float64) // Nice expands the input range of this scale to "nice" values // for covering the input range with n major ticks. After // calling Nice(n), the first and last major ticks returned by // Ticks(n) will equal the lower and upper bounds of the input // range. Nice(n int) }
A Quantative scale is an invertible function from some continuous input range to an output domain of [0, 1].
Click to show internal directories.
Click to hide internal directories.