Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public abstract class 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
From Series
getName, setName, getColor, setColor, isVisible, setVisible, isSecondaryAxis, setSecondaryAxis, isShowValues, setShowValues, getValueFormatter, setValueFormatter, getChart, getXBounds, getXBoundsWithin, getYBounds, paint, hitTest, getSelectablePointCount, isPointCountFromLayout, getPoint, paintLegendSymbol, transitionEnded, formatValue, handleTap, attached, detached, dataChanged, repaintChart, getVisibilityFraction, isGap, lerp
Constructor details
CategoricalSeries
protected CategoricalSeries(String name)Parameters
nameString- the series name
Method details
isCartesian
public boolean isCartesian()setData
public CategoricalSeries setData(String[] labels, double[] values)Parameters
labelsString[]- the name of each part
valuesdouble[]- the value of each part, parallel to the labels
Returns
setValue
public CategoricalSeries setValue(int i, double value)Parameters
iint- the part index
valuedouble- the new value
Returns
setColors
public CategoricalSeries setColors(int... rgb)Parameters
rgbint...- one colour per part
Returns
size
public int size()getLabel
public String getLabel(int i)i.getValue
public double getValue(int i)i.getColor
public int getColor(int i)i.isShown
public boolean isShown(int i)i is shown.displayValue
protected double displayValue(ChartContext ctx, int i)i in the current frame of an animation; hidden parts shrink to 0.Parameters
ctxChartContext- the paint context
iint- the part index
Returns
isEntering
protected boolean isEntering(ChartContext ctx)Parameters
ctxChartContext- the paint context
Returns
displayTotal
protected double displayTotal(ChartContext ctx)Parameters
ctxChartContext- the paint context
Returns
getTotal
public double getTotal()largestShown
protected double largestShown()Returns
scaledShownTotal
protected double scaledShownTotal(double maxPart)maxPart.Parameters
maxPartdouble- the value of
largestShown()
Returns
percentOf
protected double percentOf(int i, double maxPart, double scaledTotal)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
iint- the part index
maxPartdouble- the largest shown value
scaledTotaldouble- the total scaled by
maxPart
Returns
captureTransitionStart
protected void captureTransitionStart()captureEntryStart
protected void captureEntryStart()getLegendEntryCount
public int getLegendEntryCount()getLegendEntryName
public String getLegendEntryName(int i)i.paintLegendEntrySymbol
public void paintLegendEntrySymbol(Graphics g, int i, int x, int y, int size)i.isLegendEntryVisible
public boolean isLegendEntryVisible(int i)i is visible; a pie slice can be hidden on its own.toggleLegendEntry
public void toggleLegendEntry(int i)i.getPointCount
public int getPointCount()formatTooltip
public String formatTooltip(ChartContext ctx, ChartPoint p)Parameters
ctxChartContext- the last paint context
pChartPoint- the point
Returns
point
protected ChartPoint point(ChartContext ctx, int i, float sx, float sy)i at a screen position.Parameters
ctxChartContext- the paint context
iint- the part index
sxfloat- absolute screen x of the part’s anchor
syfloat- absolute screen y of the part’s anchor
Returns
collectTableRows
public void collectTableRows(List<String[]> rows){series, item, value} row per point.
Used by Chart.toTable() and the chart’s accessibility text.Parameters
rowsList<String[]>- the list to append rows to