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

public class BoxPlotSeries

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

Box and whisker plots: the median, the interquartile box and the whiskers of each group.

Give it the five numbers directly or let it compute them from raw samples:

double[] mondaySamples = {120, 135, 150, 180, 240};
double[] tuesdaySamples = {110, 125, 140, 160, 300};
BoxPlotSeries s = new BoxPlotSeries("Latency");
s.addSamples(0, mondaySamples);
s.addSamples(1, tuesdaySamples);

A box plot

Constructors

public BoxPlotSeries(String name)Creates an empty series.

Methods

public BoxPlotSeries addBox(double x, double min, double q1, double median, double q3, double max)Appends a box from its five numbers.
public BoxPlotSeries addSamples(double x, double[] samples)Appends a box computed from raw samples.
public double[] getOutliers(int i)The outliers of box i: the samples addSamples placed beyond the whiskers.
public double getMin(int i)The lower whisker of box i.
public double getMax(int i)The upper whisker of box i.
protected void dataChanged()Forgets the outliers of boxes that are no longer in the series, such as one a slide dropped; they are dropped when the outliers are next read.
public static double quantile(double[] sorted, double q)Linear interpolated quantile of sorted data.
public BoxPlotSeries setBoxFraction(float f)The fraction of each slot a box takes.
public double[] getYBounds()The extent of the data along y, {min, max}, or null when empty or not cartesian.
public double[] getXBounds()The extent of the data along x, {min, max}, or null when empty or not cartesian.
public void paint(ChartContext ctx)Paints the series.
public String formatTooltip(ChartContext ctx, ChartPoint p)The tooltip row for a point: the series or point name and its formatted value.
protected String tableValue(int i)The text of point i in the accessible data table.

Inherited methods

Constructor details

BoxPlotSeries

public BoxPlotSeries(String name)
Creates an empty series.

Parameters

name String
the series name

Method details

addBox

public BoxPlotSeries addBox(double x, double min, double q1, double median, double q3, double max)
Appends a box from its five numbers.

Parameters

x double
the group’s x value
min double
the lower whisker
q1 double
the first quartile
median double
the median
q3 double
the third quartile
max double
the upper whisker

Returns

this series

addSamples

public BoxPlotSeries addSamples(double x, double[] samples)
Appends a box computed from raw samples. The whiskers reach the furthest samples within 1.5 times the interquartile range of the box (Tukey’s rule) and every sample beyond them is an outlier, drawn as a dot and returned by getOutliers(int).

Parameters

x double
the group’s x value
samples double[]
the values; the array is not modified

Returns

this series

getOutliers

public double[] getOutliers(int i)
The outliers of box i: the samples addSamples placed beyond the whiskers. A box given by addBox has none.

Parameters

i int
the box index

Returns

a new array, empty when there are none

getMin

public double getMin(int i)
The lower whisker of box i.

Parameters

i int
the box index

Returns

the lower whisker’s value

getMax

public double getMax(int i)
The upper whisker of box i.

Parameters

i int
the box index

Returns

the upper whisker’s value

dataChanged

protected void dataChanged()
Forgets the outliers of boxes that are no longer in the series, such as one a slide dropped; they are dropped when the outliers are next read.

quantile

public static double quantile(double[] sorted, double q)
Linear interpolated quantile of sorted data.

Parameters

sorted double[]
ascending values
q double
the quantile, 0 to 1

Returns

the quantile

setBoxFraction

public BoxPlotSeries setBoxFraction(float f)
The fraction of each slot a box takes.

Parameters

f float
0.1 to 1

Returns

this series

getYBounds

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

getXBounds

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

paint

public void paint(ChartContext ctx)
Paints the series.

Parameters

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

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

tableValue

protected String tableValue(int i)
The text of point i in the accessible data table.

Parameters

i int
the point index

Returns

the formatted value