Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public final class Ticks

  1. Object
  2. 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

rough double
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

min double
the visible minimum
max double
the visible maximum
maxCount int
the largest number of ticks the space allows, at least 2

Returns

the tick values inside [min, max], ascending

decimalsFor

public static int decimalsFor(double step)
The decimal places needed to print every multiple of step exactly.

Parameters

step double
the tick step

Returns

0 for integral steps, otherwise the number of significant decimals (capped at 10)