Class PieSeries


public class PieSeries extends CategoricalSeries

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);

A pie A doughnut

  • Field Details

    • LABELS_OUTSIDE

      public static final int LABELS_OUTSIDE
      Names and percentages outside the pie on leader lines.
      See Also:
    • LABELS_INSIDE

      public static final int LABELS_INSIDE
      Percentages inside slices large enough to hold them.
      See Also:
    • LABELS_NONE

      public static final int LABELS_NONE
      No labels; the legend and tooltip name the slices.
      See Also:
  • Constructor Details

    • PieSeries

      public PieSeries(String name)

      Creates an empty pie.

      Parameters
      • name: the series name
  • Method Details

    • setInnerRadius

      public PieSeries setInnerRadius(float fraction)

      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

      public PieSeries setStartAngle(double deg)

      Where the first slice starts.

      Parameters
      • deg: degrees clockwise from twelve o'clock
      Returns

      this series

    • setLabelMode

      public PieSeries setLabelMode(int mode)

      Chooses where labels go.

      Parameters
      • mode: LABELS_OUTSIDE, LABELS_INSIDE or LABELS_NONE
      Returns

      this series

    • setCenterText

      public PieSeries setCenterText(String text)

      Text shown in the hole of a doughnut, usually the total.

      Parameters
      • text: the text, or null
      Returns

      this series

    • setPadAngle

      public PieSeries setPadAngle(float deg)

      The gap between slices.

      Parameters
      • deg: the gap in degrees, 0 for none
      Returns

      this series

    • paint

      public void paint(ChartContext ctx)
      Description copied from class: Series

      Paints the series.

      Parameters
      • ctx: the current frame: graphics, plot area, axes and animation progress
      Specified by:
      paint in class Series
    • hitTest

      public ChartPoint hitTest(ChartContext ctx, int x, int y, int radius)
      Description copied from class: Series

      Finds 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

      Overrides:
      hitTest in class Series
    • getPoint

      public ChartPoint getPoint(ChartContext ctx, int i)
      Description copied from class: Series
      The point at index for a shared tooltip, or null.
      Overrides:
      getPoint in class Series