Class PieSeries
java.lang.Object
com.codename1.ui.chart.Series
com.codename1.ui.chart.series.CategoricalSeries
com.codename1.ui.chart.series.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);

-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intPercentages inside slices large enough to hold them.static final intNo labels; the legend and tooltip name the slices.static final intNames and percentages outside the pie on leader lines. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetPoint(ChartContext ctx, int i) The point atindexfor a shared tooltip, or null.hitTest(ChartContext ctx, int x, int y, int radius) Finds the data point nearest a screen position.voidpaint(ChartContext ctx) Paints the series.setCenterText(String text) Text shown in the hole of a doughnut, usually the total.setInnerRadius(float fraction) Makes it a doughnut.setLabelMode(int mode) Chooses where labels go.setPadAngle(float deg) The gap between slices.setStartAngle(double deg) Where the first slice starts.Methods inherited from class CategoricalSeries
captureEntryStart, captureTransitionStart, collectTableRows, displayTotal, displayValue, formatTooltip, getColor, getLabel, getLegendEntryCount, getLegendEntryName, getPointCount, getTotal, getValue, isCartesian, isEntering, isLegendEntryVisible, isShown, largestShown, paintLegendEntrySymbol, percentOf, point, scaledShownTotal, setColors, setData, setValue, size, toggleLegendEntryMethods inherited from class Series
attached, dataChanged, detached, formatValue, getChart, getColor, getName, getSelectablePointCount, getValueFormatter, getVisibilityFraction, getXBounds, getXBoundsWithin, getYBounds, handleTap, isGap, isPointCountFromLayout, isSecondaryAxis, isShowValues, isVisible, lerp, paintLegendSymbol, repaintChart, setColor, setName, setSecondaryAxis, setShowValues, setValueFormatter, setVisible, transitionEnded
-
Field Details
-
LABELS_OUTSIDE
public static final int LABELS_OUTSIDENames and percentages outside the pie on leader lines.- See Also:
-
LABELS_INSIDE
public static final int LABELS_INSIDEPercentages inside slices large enough to hold them.- See Also:
-
LABELS_NONE
public static final int LABELS_NONENo labels; the legend and tooltip name the slices.- See Also:
-
-
Constructor Details
-
PieSeries
Creates an empty pie.
Parameters
name: the series name
-
-
Method Details
-
setInnerRadius
Makes it a doughnut.
Parameters
fraction: the hole's radius as a fraction of the outer radius, 0 for a full pie
Returns
this series
-
setStartAngle
Where the first slice starts.
Parameters
deg: degrees clockwise from twelve o'clock
Returns
this series
-
setLabelMode
Chooses where labels go.
Parameters
mode:LABELS_OUTSIDE,LABELS_INSIDEorLABELS_NONE
Returns
this series
-
setCenterText
-
setPadAngle
The gap between slices.
Parameters
deg: the gap in degrees, 0 for none
Returns
this series
-
paint
Description copied from class:SeriesPaints the series.
Parameters
ctx: the current frame: graphics, plot area, axes and animation progress
-
hitTest
Description copied from class:SeriesFinds the data point nearest a screen position.
Parameters
-
ctx: the frame the series was last painted in -
x: chart relative x -
y: chart relative y -
radius: how far from the point a touch may land and still hit it
Returns
the point, or null
-
-
getPoint
Description copied from class:SeriesThe point atindexfor a shared tooltip, or null.
-