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

public class CategoryAxis

  1. Object
  2. Axis
  3. CategoryAxis

An axis of named, evenly spaced categories. Category i sits at value i, in the middle of its band, so bars and points line up with their label.

When labels do not fit side by side the chart first rotates them, then shows every n-th one, and finally truncates with an ellipsis; it never draws them over each other.

Long category names, rotated to fit

Constructors

public CategoryAxis(int position, String... labels)Creates a category axis.

Methods

public CategoryAxis setCategories(String... labels)Replaces the category names.
public int getCategoryCount()The number of categories.
public String getCategory(int i)The name of category i, or an empty string out of range.
public void setDataBounds(double min, double max)Called by the chart with the extent of the data on this axis.
public double getDataLimit()The largest x a data point may have and still open its own band; a point further out is an outlier the axis ignores.
protected double[] adjustBounds(double min, double max)Lets a subclass pad or round the automatic bounds; the default rounds a numeric range outward to the nearest nice step so the outermost grid lines sit on the plot edge.
public double[] ticks(int maxCount)Ticks for the visible range.
protected String defaultFormat(double value, double step)The axis’ built in formatting; numbers are grouped and localized.
public double getBandWidth()The width of one category band in normalized units, used to size bars.

Inherited fields

Inherited methods

Constructor details

CategoryAxis

public CategoryAxis(int position, String... labels)
Creates a category axis.

Parameters

position int
one of Axis.BOTTOM, Axis.LEFT, Axis.RIGHT or Axis.TOP
labels String...
the category names, in order

Method details

setCategories

public CategoryAxis setCategories(String... labels)
Replaces the category names.

getCategoryCount

public int getCategoryCount()
The number of categories.

getCategory

public String getCategory(int i)
The name of category i, or an empty string out of range.

setDataBounds

public void setDataBounds(double min, double max)
Called by the chart with the extent of the data on this axis.

Parameters

min double
smallest value of any visible series
max double
largest value of any visible series

getDataLimit

public double getDataLimit()
The largest x a data point may have and still open its own band; a point further out is an outlier the axis ignores.

Returns

the largest x that counts

adjustBounds

protected double[] adjustBounds(double min, double max)
Lets a subclass pad or round the automatic bounds; the default rounds a numeric range outward to the nearest nice step so the outermost grid lines sit on the plot edge.

Parameters

min double
the raw minimum
max double
the raw maximum

Returns

{min, max} to use

ticks

public double[] ticks(int maxCount)
Ticks for the visible range.

Parameters

maxCount int
the most ticks the measured label size allows

Returns

ascending tick values

defaultFormat

protected String defaultFormat(double value, double step)
The axis’ built in formatting; numbers are grouped and localized.

getBandWidth

public double getBandWidth()
The width of one category band in normalized units, used to size bars.