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

public abstract class Series

  1. Object
  2. Series

Known subtypesCategoricalSeries, GaugeSeries, HeatmapSeries, HierarchySeries, RadarSeries, SankeySeries, XYSeries

One data series. A series owns its data, its colour and how it paints itself; there is no separate renderer object to keep in step with it.

Changing data through a series’ own methods animates the chart from the old values to the new ones. Batch several changes inside Chart.update(Runnable) to animate them as one transition.

Constructors

protected Series(String name)Creates a named series.

Methods

public String getName()The legend name.
public Series setName(String name)Renames the series.
public int getColor()The explicit colour, or the theme colour for this series’ position.
public Series setColor(int rgb)Fixes the series colour instead of taking it from the theme palette.
public boolean isVisible()False while the user has hidden it from the legend or the app hid it.
public Series setVisible(boolean visible)Shows or hides the series with an animated transition.
public boolean isSecondaryAxis()True when the series is measured against the right hand value axis.
public Series setSecondaryAxis(boolean secondaryAxis)Plots the series against the secondary (right) value axis.
public boolean isShowValues()True when value labels are drawn next to the data.
public Series setShowValues(boolean showValues)Draws value labels on the data.
public ValueFormatter getValueFormatter()Formatter for value labels and the tooltip, or null to use the value axis'.
public Series setValueFormatter(ValueFormatter valueFormatter)Sets how values print in labels and tooltips.
public Chart getChart()The chart this series is in, or null.
public abstract boolean isCartesian()True for series drawn against x and y axes; false for pies, treemaps and other series that fill the plot themselves.
public double[] getXBounds()The extent of the data along x, {min, max}, or null when empty or not cartesian.
public double[] getXBoundsWithin(double maxX)The extent along x of the data at or below maxX, {min, max}, or null when none is.
public double[] getYBounds()The extent of the data along y, {min, max}, or null when empty or not cartesian.
public abstract void paint(ChartContext ctx)Paints the series.
public ChartPoint hitTest(ChartContext ctx, int x, int y, int radius)Finds the data point nearest a screen position.
public int getPointCount()The number of points along x, for a shared tooltip; -1 when not index aligned.
public int getSelectablePointCount()The number of points Chart.setSelection and arrow-key stepping can reach by index.
protected boolean isPointCountFromLayout()True when getPointCount() counts points a paint laid out (treemap, sunburst, Sankey) rather than the model’s points, so an index past it may exist after the next paint.
public ChartPoint getPoint(ChartContext ctx, int index)The point at index for a shared tooltip, or null.
public void paintLegendSymbol(Graphics g, int x, int y, int size)Paints the legend swatch.
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.
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.
protected void transitionEnded()Called by the chart when a transition has finished, so a subclass can drop the start values it captured; a later change that forgot to snapshot then shows its new values instead of replaying a transition from long gone data.
public String formatValue(ChartContext ctx, double value)Formats a value for a label or tooltip.
public String formatTooltip(ChartContext ctx, ChartPoint p)The tooltip row for a point: the series or point name and its formatted value.
public void collectTableRows(List<String[]> rows)Adds this series’ data to an accessible table, one {series, item, value} row per point.
public boolean handleTap(ChartPoint p)Called when a point of this series is tapped, before the chart selects it.
protected void attached()Called by the chart when this series is added to it, and again when the chart comes back on screen (its initComponent); a series may be told more than once.
protected void detached()Called by the chart when this series is removed from it, or the chart leaves the screen (its deinitialize); a series may be told more than once.
protected void dataChanged()Tells the chart this series’ data changed, which animates the new values in.
protected void repaintChart()Repaints without a transition.
protected float getVisibilityFraction()The current shown fraction, 0 hidden to 1 shown, animated while the user toggles it.
protected static boolean isGap(double v)True for a value that cannot be plotted: NaN or either infinity.
protected static double lerp(double a, double b, double t)Interpolates for transitions; a start that is a gap (NaN or infinite) means the value appears without a tween, since every in-between value of an infinite start is NaN or infinite and the point would vanish for the whole transition.

Inherited methods

Constructor details

Series

protected Series(String name)
Creates a named series.

Parameters

name String
shown in the legend and the tooltip

Method details

getName

public String getName()
The legend name.

setName

public Series setName(String name)
Renames the series.

getColor

public int getColor()
The explicit colour, or the theme colour for this series’ position.

setColor

public Series setColor(int rgb)
Fixes the series colour instead of taking it from the theme palette.

isVisible

public boolean isVisible()
False while the user has hidden it from the legend or the app hid it.

setVisible

public Series setVisible(boolean visible)
Shows or hides the series with an animated transition.

isSecondaryAxis

public boolean isSecondaryAxis()
True when the series is measured against the right hand value axis.

setSecondaryAxis

public Series setSecondaryAxis(boolean secondaryAxis)
Plots the series against the secondary (right) value axis.

isShowValues

public boolean isShowValues()
True when value labels are drawn next to the data. Labels that would collide are left out rather than drawn over each other.

setShowValues

public Series setShowValues(boolean showValues)
Draws value labels on the data.

getValueFormatter

public ValueFormatter getValueFormatter()
Formatter for value labels and the tooltip, or null to use the value axis'.

setValueFormatter

public Series setValueFormatter(ValueFormatter valueFormatter)
Sets how values print in labels and tooltips.

getChart

public Chart getChart()
The chart this series is in, or null.

isCartesian

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

getXBounds

public double[] getXBounds()
The extent of the data along x, {min, max}, or null when empty or not cartesian.

getXBoundsWithin

public double[] getXBoundsWithin(double maxX)
The extent along x of the data at or below maxX, {min, max}, or null when none is. A category axis with no labels asks for this to leave a far outlier out of its bands.

Parameters

maxX double
the largest x that counts

Returns

the bounds of the points that count, or null

getYBounds

public double[] getYBounds()
The extent of the data along y, {min, max}, or null when empty or not cartesian.

paint

public abstract void paint(ChartContext ctx)
Paints the series.

Parameters

ctx ChartContext
the current frame: graphics, plot area, axes and animation progress

hitTest

public ChartPoint hitTest(ChartContext ctx, int x, int y, int radius)
Finds the data point nearest a screen position.

Parameters

ctx ChartContext
the frame the series was last painted in
x int
chart relative x
y int
chart relative y
radius int
how far from the point a touch may land and still hit it

Returns

the point, or null

getPointCount

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

getSelectablePointCount

public int getSelectablePointCount()
The number of points Chart.setSelection and arrow-key stepping can reach by index. The same as getPointCount(), except for a series whose points are not index aligned with other series (scatter), which still has its own points to select.

isPointCountFromLayout

protected boolean isPointCountFromLayout()
True when getPointCount() counts points a paint laid out (treemap, sunburst, Sankey) rather than the model’s points, so an index past it may exist after the next paint.

getPoint

public ChartPoint getPoint(ChartContext ctx, int index)
The point at index for a shared tooltip, or null.

paintLegendSymbol

public void paintLegendSymbol(Graphics g, int x, int y, int size)
Paints the legend swatch.

Parameters

g Graphics
graphics
x int
swatch left
y int
swatch top
size int
swatch size

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.

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.

transitionEnded

protected void transitionEnded()
Called by the chart when a transition has finished, so a subclass can drop the start values it captured; a later change that forgot to snapshot then shows its new values instead of replaying a transition from long gone data.

formatValue

public String formatValue(ChartContext ctx, double value)
Formats a value for a label or tooltip.

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

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

handleTap

public boolean handleTap(ChartPoint p)
Called when a point of this series is tapped, before the chart selects it. A series that navigates on tap (drilling into a treemap node) returns true to stop the selection.

Parameters

p ChartPoint
the tapped point

Returns

true if the tap was consumed

attached

protected void attached()
Called by the chart when this series is added to it, and again when the chart comes back on screen (its initComponent); a series may be told more than once. A series that listens to a model outliving it (a TreeNode tree) registers here, so the model does not keep a discarded chart reachable: a chart taken off screen, or a series removed from its chart, stops listening.

detached

protected void detached()
Called by the chart when this series is removed from it, or the chart leaves the screen (its deinitialize); a series may be told more than once. Undoes attached().

dataChanged

protected void dataChanged()
Tells the chart this series’ data changed, which animates the new values in.

repaintChart

protected void repaintChart()
Repaints without a transition.

getVisibilityFraction

protected float getVisibilityFraction()
The current shown fraction, 0 hidden to 1 shown, animated while the user toggles it.

isGap

protected static boolean isGap(double v)
True for a value that cannot be plotted: NaN or either infinity. Such a point is a gap, drawn as nothing and kept out of every axis bound.

lerp

protected static double lerp(double a, double b, double t)
Interpolates for transitions; a start that is a gap (NaN or infinite) means the value appears without a tween, since every in-between value of an infinite start is NaN or infinite and the point would vanish for the whole transition.