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

public class ScatterSeries

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

Unconnected points. Giving the points sizes turns it into a bubble chart: the bubble’s area, not its radius, is proportional to the size value, so big values do not look quadratically bigger than they are.

A scatter chart A bubble chart

Constructors

public ScatterSeries(String name)Creates an empty scatter series.

Methods

public ScatterSeries setSizes(double... sizes)Sets a size per point of the points the series holds now, making this a bubble series; null for plain points.
public ScatterSeries setData(double[] x, double[] y, double[] sizes)Replaces all points with bubbles of the given sizes.
public ScatterSeries add(double x, double y, double size)Appends a bubble, sliding the window when a maximum is set.
public double getSize(int i)The size of point i, NaN when it has none.
protected boolean isAuxRelative(int channel)True when extra channel channel is a value on the y scale (a high, a low, a quartile) and so animates as an offset from the point’s value; false for a channel of its own scale, such as a bubble size, which animates by itself.
protected double auxDefault(int channel, double y)
public ScatterSeries setPointSize(float mm)Diameter of plain points in millimetres.
public ScatterSeries setMaxBubbleSize(float mm)Diameter of the largest bubble in millimetres.
public 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.
public double[] getXBounds()The extent of the data along x, {min, max}, or null when empty or not cartesian.
public double[] getYBounds()The extent of the data along y, {min, max}, or null when empty or not cartesian.

Inherited methods

Constructor details

ScatterSeries

public ScatterSeries(String name)
Creates an empty scatter series.

Parameters

name String
the legend name

Method details

setSizes

public ScatterSeries setSizes(double... sizes)
Sets a size per point of the points the series holds now, making this a bubble series; null for plain points. A point past the end of sizes, or with a NaN size, is drawn as a plain dot. Sizes move with their points as points are added, removed or slide out of a setMaxPoints window; use setData(double[], double[], double[]) or add(double, double, double) to give new points theirs.

setData

public ScatterSeries setData(double[] x, double[] y, double[] sizes)
Replaces all points with bubbles of the given sizes.

Parameters

x double[]
x values, or null for 0, 1, 2…
y double[]
the values
sizes double[]
one size per point, NaN for a plain dot; null for plain points, as setSizes(null) does

add

public ScatterSeries add(double x, double y, double size)
Appends a bubble, sliding the window when a maximum is set.

Parameters

x double
the x value
y double
the value
size double
the bubble size, NaN for a plain dot

getSize

public double getSize(int i)
The size of point i, NaN when it has none.

isAuxRelative

protected boolean isAuxRelative(int channel)
True when extra channel channel is a value on the y scale (a high, a low, a quartile) and so animates as an offset from the point’s value; false for a channel of its own scale, such as a bubble size, which animates by itself.

Parameters

channel int
the extra channel

Returns

true by default

auxDefault

protected double auxDefault(int channel, double y)

setPointSize

public ScatterSeries setPointSize(float mm)
Diameter of plain points in millimetres.

setMaxBubbleSize

public ScatterSeries setMaxBubbleSize(float mm)
Diameter of the largest bubble in millimetres.

paint

public 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.

getXBounds

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

getYBounds

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