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

public class LineSeries

  1. Object
  2. Series
  3. XYSeries
  4. LineSeries

A line, spline, step or area series.

Splines are monotone cubic curves: they pass through every point and never overshoot between two of them, so a smoothed line cannot invent a peak the data does not have. Dense data is reduced to the minimum and maximum of each pixel column before drawing, which keeps every spike while painting a constant number of segments.

Lines with markers A spline A step line Stacked areas

Fields

public static final int STRAIGHT = 0Straight segments between points.
public static final int SPLINE = 1A monotone cubic curve through the points.
public static final int STEP = 2A horizontal run to each point’s x, then a vertical step.

Constructors

public LineSeries(String name)Creates an empty line series.

Methods

public LineSeries setMode(int mode)STRAIGHT, SPLINE or STEP.
public int getMode()The drawing mode.
public LineSeries setFilled(boolean fill)Fills the area under the line, turning it into an area series; stacked areas need a shared setStackGroup.
public boolean isFilled()True for an area series.
public LineSeries setFillAlpha(int alpha)Opacity of the area fill, 0 to 255.
public LineSeries setLineWidth(float mm)Line thickness in millimetres.
public LineSeries setMarkers(boolean markers)Draws a dot at every point (skipped automatically when points are too dense to tell apart).
public LineSeries setDashed(boolean dashed)Draws a dashed line, for targets and forecasts.
protected boolean consumesStackBase()True for a series drawn on its stack base (an area or a bar), which a stack group lifts and whose layer shrinks with the fraction it is shown while it fades; false for marks that keep their own values (scatter, error bars, candles, boxes).
public void paint(ChartContext ctx)Paints the series.

Inherited methods

Field details

STRAIGHT

public static final int STRAIGHT = 0
Straight segments between points.

SPLINE

public static final int SPLINE = 1
A monotone cubic curve through the points.

STEP

public static final int STEP = 2
A horizontal run to each point’s x, then a vertical step.

Constructor details

LineSeries

public LineSeries(String name)
Creates an empty line series.

Parameters

name String
the legend name

Method details

setMode

public LineSeries setMode(int mode)
STRAIGHT, SPLINE or STEP.

getMode

public int getMode()
The drawing mode.

setFilled

public LineSeries setFilled(boolean fill)
Fills the area under the line, turning it into an area series; stacked areas need a shared setStackGroup.

isFilled

public boolean isFilled()
True for an area series.

setFillAlpha

public LineSeries setFillAlpha(int alpha)
Opacity of the area fill, 0 to 255.

setLineWidth

public LineSeries setLineWidth(float mm)
Line thickness in millimetres.

setMarkers

public LineSeries setMarkers(boolean markers)
Draws a dot at every point (skipped automatically when points are too dense to tell apart).

setDashed

public LineSeries setDashed(boolean dashed)
Draws a dashed line, for targets and forecasts.

consumesStackBase

protected boolean consumesStackBase()
True for a series drawn on its stack base (an area or a bar), which a stack group lifts and whose layer shrinks with the fraction it is shown while it fades; false for marks that keep their own values (scatter, error bars, candles, boxes).

Returns

false by default

paint

public void paint(ChartContext ctx)
Paints the series.

Parameters

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