Class Ticks

java.lang.Object
com.codename1.ui.chart.axis.Ticks

public final class Ticks extends Object
"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.
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    decimalsFor(double step)
    The decimal places needed to print every multiple of step exactly.
    static double[]
    linear(double min, double max, int maxCount)
    Generates ticks covering [min, max] with at most maxCount ticks.
    static double
    niceStep(double rough)
    Returns a round step close to rough.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • niceStep

      public static double niceStep(double rough)

      Returns a round step close to rough.

      Parameters
      • rough: 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: the visible minimum

      • max: the visible maximum

      • maxCount: 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: the tick step
      Returns

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