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

public abstract class CategoricalSeries

  1. Object
  2. Series
  3. CategoricalSeries

Known subtypesFunnelSeries, PieSeries

Base of series made of named parts that fill the plot: pie slices, funnel stages.

Each part gets its own legend entry and colour from the theme palette, and can be hidden on its own by tapping its legend entry; the others animate to fill the gap.

Constructors

protected CategoricalSeries(String name)Creates an empty series.

Methods

public boolean isCartesian()True for series drawn against x and y axes; false for pies, treemaps and other series that fill the plot themselves.
public CategoricalSeries setData(String[] labels, double[] values)Replaces all parts.
public CategoricalSeries setValue(int i, double value)Changes the value of one part, animated.
public CategoricalSeries setColors(int... rgb)Fixes the colour of each part instead of using the theme palette.
public int size()The number of parts.
public String getLabel(int i)The name of part i.
public double getValue(int i)The value of part i.
public int getColor(int i)The colour of part i.
public boolean isShown(int i)True if part i is shown.
protected double displayValue(ChartContext ctx, int i)The value of part i in the current frame of an animation; hidden parts shrink to 0.
protected boolean isEntering(ChartContext ctx)True while the first appearance animation runs.
protected double displayTotal(ChartContext ctx)The sum of the displayed values.
public double getTotal()The sum of the visible target values, for percentages.
protected double largestShown()The largest value a percentage is taken of: shown, positive and finite; 0 when none.
protected double scaledShownTotal(double maxPart)The total of the shown values, each divided by maxPart.
protected double percentOf(int i, double maxPart, double scaledTotal)The percentage part i is of the shown parts, given the base from largestShown() and scaledShownTotal(); negative when the part has no share to print (hidden, NaN, negative or infinite).
protected void captureTransitionStart()Records the values currently on screen as the start of the next transition.
protected void captureEntryStart()Records a zero baseline as the start of the entry animation.
public int getLegendEntryCount()Entries this series contributes to the legend; a single series by default, one per slice for a pie.
public String getLegendEntryName(int i)The name of legend entry i.
public void paintLegendEntrySymbol(Graphics g, int i, int x, int y, int size)Paints the swatch of legend entry i.
public boolean isLegendEntryVisible(int i)True if entry i is visible; a pie slice can be hidden on its own.
public void toggleLegendEntry(int i)Toggles legend entry i.
public int getPointCount()The number of points along x, for a shared tooltip; -1 when not index aligned.
public String formatTooltip(ChartContext ctx, ChartPoint p)The tooltip row for a point: the series or point name and its formatted value.
protected ChartPoint point(ChartContext ctx, int i, float sx, float sy)A point describing part i at a screen position.
public void collectTableRows(List<String[]> rows)Adds this series’ data to an accessible table, one {series, item, value} row per point.

Inherited methods

Constructor details

CategoricalSeries

protected CategoricalSeries(String name)
Creates an empty series.

Parameters

name String
the series name

Method details

isCartesian

public boolean isCartesian()
True for series drawn against x and y axes; false for pies, treemaps and other series that fill the plot themselves.

setData

public CategoricalSeries setData(String[] labels, double[] values)
Replaces all parts.

Parameters

labels String[]
the name of each part
values double[]
the value of each part, parallel to the labels

Returns

this series

setValue

public CategoricalSeries setValue(int i, double value)
Changes the value of one part, animated.

Parameters

i int
the part index
value double
the new value

Returns

this series

setColors

public CategoricalSeries setColors(int... rgb)
Fixes the colour of each part instead of using the theme palette.

Parameters

rgb int...
one colour per part

Returns

this series

size

public int size()
The number of parts.

getLabel

public String getLabel(int i)
The name of part i.

getValue

public double getValue(int i)
The value of part i.

getColor

public int getColor(int i)
The colour of part i.

isShown

public boolean isShown(int i)
True if part i is shown.

displayValue

protected double displayValue(ChartContext ctx, int i)
The value of part i in the current frame of an animation; hidden parts shrink to 0.

Parameters

ctx ChartContext
the paint context
i int
the part index

Returns

the displayed value

isEntering

protected boolean isEntering(ChartContext ctx)
True while the first appearance animation runs.

Parameters

ctx ChartContext
the paint context

Returns

true during the entry animation

displayTotal

protected double displayTotal(ChartContext ctx)
The sum of the displayed values.

Parameters

ctx ChartContext
the paint context

Returns

the total

getTotal

public double getTotal()
The sum of the visible target values, for percentages.

largestShown

protected double largestShown()
The largest value a percentage is taken of: shown, positive and finite; 0 when none.

Returns

the largest shown value

scaledShownTotal

protected double scaledShownTotal(double maxPart)
The total of the shown values, each divided by maxPart.

Parameters

maxPart double
the value of largestShown()

Returns

the scaled total

percentOf

protected double percentOf(int i, double maxPart, double scaledTotal)
The percentage part i is of the shown parts, given the base from largestShown() and scaledShownTotal(); negative when the part has no share to print (hidden, NaN, negative or infinite).

Parameters

i int
the part index
maxPart double
the largest shown value
scaledTotal double
the total scaled by maxPart

Returns

the percentage, or a negative number

captureTransitionStart

protected void captureTransitionStart()
Records the values currently on screen as the start of the next transition. Called by the chart before data changes; a subclass with animated data overrides it.

captureEntryStart

protected void captureEntryStart()
Records a zero baseline as the start of the entry animation.

getLegendEntryCount

public int getLegendEntryCount()
Entries this series contributes to the legend; a single series by default, one per slice for a pie.

getLegendEntryName

public String getLegendEntryName(int i)
The name of legend entry i.

paintLegendEntrySymbol

public void paintLegendEntrySymbol(Graphics g, int i, int x, int y, int size)
Paints the swatch of legend entry i.

isLegendEntryVisible

public boolean isLegendEntryVisible(int i)
True if entry i is visible; a pie slice can be hidden on its own.

toggleLegendEntry

public void toggleLegendEntry(int i)
Toggles legend entry i.

getPointCount

public int getPointCount()
The number of points along x, for a shared tooltip; -1 when not index aligned.

formatTooltip

public String formatTooltip(ChartContext ctx, ChartPoint p)
The tooltip row for a point: the series or point name and its formatted value. Series with several values per point (open/high/low/close, ranges, box plots) override this.

Parameters

ctx ChartContext
the last paint context
p ChartPoint
the point

Returns

one line of text

point

protected ChartPoint point(ChartContext ctx, int i, float sx, float sy)
A point describing part i at a screen position.

Parameters

ctx ChartContext
the paint context
i int
the part index
sx float
absolute screen x of the part’s anchor
sy float
absolute screen y of the part’s anchor

Returns

the point

collectTableRows

public void collectTableRows(List<String[]> rows)
Adds this series’ data to an accessible table, one {series, item, value} row per point. Used by Chart.toTable() and the chart’s accessibility text.

Parameters

rows List<String[]>
the list to append rows to