Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public final class Ticks
- Object
- Ticks
“Nice number” tick generation: steps of 1, 2, 2.5 or 5 times a power of ten, so axis
labels read as round values instead of whatever the data range happened to divide into.
Methods
public static double niceStep(double rough) | Returns a round step close to rough. |
public static double[] linear(double min, double max, int maxCount) | Generates ticks covering [min, max] with at most maxCount ticks. |
public static int decimalsFor(double step) | The decimal places needed to print every multiple of step exactly. |
Inherited methods
Method details
niceStep
public static double niceStep(double rough)Returns a round step close to
rough.Parameters
roughdouble- the unrounded step,
range / desiredTickCount
Returns
the nice step, always positive; 1 for a degenerate input
linear
public static double[] linear(double min, double max, int maxCount)Generates ticks covering
[min, max] with at most maxCount ticks.Parameters
mindouble- the visible minimum
maxdouble- the visible maximum
maxCountint- the largest number of ticks the space allows, at least 2
Returns
the tick values inside
[min, max], ascendingdecimalsFor
public static int decimalsFor(double step)The decimal places needed to print every multiple of
step exactly.Parameters
stepdouble- the tick step
Returns
0 for integral steps, otherwise the number of significant decimals (capped at 10)