Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public class PieSeries
- Object
- Series
- CategoricalSeries
- PieSeries
A pie or doughnut chart.
Labels sit outside the pie on leader lines and are spread vertically so that no two overlap; when the chart is too small for them, or a slice is too thin to point at, the label is left out and the legend and tooltip carry the name instead.
Chart chart = new Chart();
PieSeries pie = new PieSeries("Share");
pie.setData(new String[]{"Android", "iOS", "Other"}, new double[]{71, 28, 1});
pie.setInnerRadius(0.6f).setCenterText("2.1B");
chart.addSeries(pie);

Fields
public static final int LABELS_OUTSIDE = 0 | Names and percentages outside the pie on leader lines. |
public static final int LABELS_INSIDE = 1 | Percentages inside slices large enough to hold them. |
public static final int LABELS_NONE = 2 | No labels; the legend and tooltip name the slices. |
Constructors
public PieSeries(String name) | Creates an empty pie. |
Methods
public PieSeries setInnerRadius(float fraction) | Makes it a doughnut. |
public PieSeries setStartAngle(double deg) | Where the first slice starts. |
public PieSeries setLabelMode(int mode) | Chooses where labels go. |
public PieSeries setCenterText(String text) | Text shown in the hole of a doughnut, usually the total. |
public PieSeries setPadAngle(float deg) | The gap between slices. |
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 ChartPoint getPoint(ChartContext ctx, int i) | The point at index for a shared tooltip, or null. |
Inherited methods
From CategoricalSeries
isCartesian, setData, setValue, setColors, size, getLabel, getValue, getColor, isShown, displayValue, isEntering, displayTotal, getTotal, largestShown, scaledShownTotal, percentOf, captureTransitionStart, captureEntryStart, getLegendEntryCount, getLegendEntryName, paintLegendEntrySymbol, isLegendEntryVisible, toggleLegendEntry, getPointCount, formatTooltip, point, collectTableRows
From Series
getName, setName, getColor, setColor, isVisible, setVisible, isSecondaryAxis, setSecondaryAxis, isShowValues, setShowValues, getValueFormatter, setValueFormatter, getChart, getXBounds, getXBoundsWithin, getYBounds, getSelectablePointCount, isPointCountFromLayout, paintLegendSymbol, transitionEnded, formatValue, handleTap, attached, detached, dataChanged, repaintChart, getVisibilityFraction, isGap, lerp
Field details
LABELS_OUTSIDE
public static final int LABELS_OUTSIDE = 0LABELS_INSIDE
public static final int LABELS_INSIDE = 1LABELS_NONE
public static final int LABELS_NONE = 2Constructor details
PieSeries
public PieSeries(String name)Parameters
nameString- the series name
Method details
setInnerRadius
public PieSeries setInnerRadius(float fraction)Parameters
fractionfloat- the hole’s radius as a fraction of the outer radius, 0 for a full pie
Returns
setStartAngle
public PieSeries setStartAngle(double deg)Parameters
degdouble- degrees clockwise from twelve o’clock
Returns
setLabelMode
public PieSeries setLabelMode(int mode)Parameters
modeintLABELS_OUTSIDE,LABELS_INSIDEorLABELS_NONE
Returns
setCenterText
public PieSeries setCenterText(String text)Parameters
textString- the text, or null
Returns
setPadAngle
public PieSeries setPadAngle(float deg)Parameters
degfloat- the gap in degrees, 0 for none
Returns
paint
public void paint(ChartContext ctx)Parameters
ctxChartContext- the current frame: graphics, plot area, axes and animation progress
hitTest
public ChartPoint hitTest(ChartContext ctx, int x, int y, int radius)Parameters
ctxChartContext- the frame the series was last painted in
xint- chart relative x
yint- chart relative y
radiusint- how far from the point a touch may land and still hit it
Returns
getPoint
public ChartPoint getPoint(ChartContext ctx, int i)index for a shared tooltip, or null.