public class LogScale extends ContinuousQuantitativeScale<LogScale>
The mapping to the output range value y can be expressed as a function of the input domain value x: y = m log(*x*) + b.
Log 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.
However, note that the domain of a log scale should never contain zero, as log(0) is negative infinity.
As with LinearScale
s, log scales can also accept more than two values
for the domain and range, thus resulting in polylog scale.
Modifier | Constructor and Description |
---|---|
protected |
LogScale() |
Modifier and Type | Method and Description |
---|---|
int |
base()
Returns the current base, which defaults to 10.
|
LogScale |
base(int b)
Sets the base for this logarithmic scale.
|
LogScale |
nice()
Extends the domain so that it starts and ends on nice round values.
|
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,
DatumFunction<String> formatFunction)
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()
Returns 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 <T> Array<T> ticks()
The returned tick values are uniformly spaced within each power of ten, 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.
Note that the number of ticks cannot be customized (due to the nature of log scales); however, you can filter the returned array of values if you want to reduce the number of ticks.
public final Formatter tickFormat()
The returned tick format is implemented as d.toPrecision(1).
public final Formatter tickFormat(int count)
The returned tick format is implemented as d.toPrecision(1).
Some of the tick labels may not be displayed; this is useful if there is not enough room to fit all of the tick labels. However, note that the tick marks will still be displayed (so that the log scale distortion remains visible).
the
- number of ticks to take into account to create the
Formatter
.public final Formatter tickFormat(int count, String formatSpecifier)
The returned tick format is implemented as d.toPrecision(1).
Some of the tick labels may not be displayed; this is useful if there is not enough room to fit all of the tick labels. However, note that the tick marks will still be displayed (so that the log scale distortion remains visible).
The format argument allow to specify a format as a string. 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.
public final Formatter tickFormat(int count, DatumFunction<String> formatFunction)
The returned tick format is implemented as d.toPrecision(1).
Some of the tick labels may not be displayed; this is useful if there is not enough room to fit all of the tick labels. However, note that the tick marks will still be displayed (so that the log scale distortion remains visible).
The format argument allow to specify a format as a string. 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.
count
- the number of ticks to take into account to create the
Formatter
.formatFunction
- the function used to format the tick labelpublic final LogScale nice()
This method typically modifies the scale's domain, and may only extend the bounds to the nearest round value.
The nearest round value is based on the nearest power of ten.
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.1, 1]. If the domain has more than two values, nicing the domain only affects the first and last value.
public final int base()
public final LogScale base(int b)
Copyright © 2015 gwt-d3. All rights reserved.