public class PowScale extends ContinuousQuantitativeScale<PowScale>
The mapping to the output range value y can be expressed as a function of the input domain value x: y = mx^k + b, where k is the exponent value.
Power scales also support negative values, in which case the input value is multiplied by -1, and the resulting output value is also multiplied by -1.
As with LinearScale
s, power scales can also accept more than two
values for the domain and range, thus resulting in polypower scale.
Modifier | Constructor and Description |
---|---|
protected |
PowScale() |
Modifier and Type | Method and Description |
---|---|
double |
exponent()
Returns the current exponent, which defaults to 1.
|
PowScale |
exponent(double e)
Sets the current exponent to the given numeric value.
|
PowScale |
nice()
Extends the domain so that it starts and ends on nice round values.
|
PowScale |
nice(int count)
Same as
nice() but with more control. |
Formatter |
tickFormat()
Returns a number format function suitable for displaying a tick value.
|
Formatter |
tickFormat(int count)
Returns a number format function suitable for displaying a tick value.
|
Formatter |
tickFormat(int count,
String formatSpecifier)
Returns a number format function suitable for displaying a tick value.
|
<T> Array<T> |
ticks()
Alias for
ticks(10) . |
<T> Array<T> |
ticks(int count)
Returns approximately count representative values from the scale's input
domain.
|
clamp, clamp, invert, rangeRound, rangeRound, rangeRound
apply, apply, apply, copy, domain, domain, domain, domain, range, range, range, range
public final double exponent()
public final PowScale exponent(double e)
public final PowScale nice()
This method typically modifies the scale's domain, and may only extend the bounds to the nearest round value.
The precision of the round value is dependent on the extent of the domain dx according to the following formula: exp(round(log(*dx*)) - 1).
Nicing is useful if the domain is computed from data and may be irregular.
For example, for a domain of [0.20147987687960267, 0.996679553296417], the nice domain is [0.2, 1]. If the domain has more than two values, nicing the domain only affects the first and last value.
public final PowScale nice(int count)
nice()
but with more control.
The tick count argument allows greater control over the step size used to
extend the bounds, guaranteeing that the ticks returned by
ticks(int)
will exactly cover the domain.
public final <T> Array<T> ticks(int count)
The returned tick values are uniformly spaced, have human-readable values (such as multiples of powers of 10), and are guaranteed to be within the extent of the input domain.
Ticks are often used to display reference lines, or tick marks, in conjunction with the visualized data. The specified count is only a hint; the scale may return more or fewer values depending on the input domain.
public final Formatter tickFormat()
The returned tick format is implemented as d.toPrecision(1).
public final Formatter tickFormat(int count)
The specified count should have the same value as the count that is used to generate the tick values you want to display.
You don't have to use the scale's built-in tick format, but it automatically computes the appropriate precision based on the fixed interval between tick values.
the
- number of ticks to take into account to create the
Formatter
.public final Formatter tickFormat(int count, String formatSpecifier)
This is the same as tickFormat(int)
, except that the format
argument allows a format specifier to be specified.
If the format specifier doesn’t have a defined precision, the precision will be set automatically by the scale, returning the appropriate format.
This provides a convenient, declarative way of specifying a format whose precision will be automatically set by the scale.
Copyright © 2015 gwt-d3. All rights reserved.