Package com.pdfjet

Class DonutChart

java.lang.Object
com.pdfjet.DonutChart
All Implemented Interfaces:
Drawable

public class DonutChart extends Object implements Drawable
A donut or pie chart: each slice is its value's share of the sum of the values, with a label next to it and its percentage inside it. A chart with an inner radius of 0 is a pie chart. See Example_28.
  • Constructor Details

    • DonutChart

      public DonutChart(Font f1, Font f2)
      Creates a donut chart. With an inner radius of 0 it is a pie chart.
      Parameters:
      f1 - the font for the slice labels.
      f2 - the font for the percentages drawn inside the slices.
  • Method Details

    • setLocation

      public DonutChart setLocation(float x, float y)
      Sets the top left corner of the outer circle of this chart. The center is one outer radius to the right of it and one below. The slice labels can extend past the circle.
      Specified by:
      setLocation in interface Drawable
      Parameters:
      x - the x coordinate of the top left corner.
      y - the y coordinate of the top left corner.
      Returns:
      this DonutChart object.
    • setRadii

      public DonutChart setRadii(float outerRadius, float innerRadius)
      Sets the outer and inner radius of this chart.
      Parameters:
      outerRadius - the outer radius.
      innerRadius - the inner radius; 0 for a pie chart.
      Returns:
      this DonutChart object.
    • addSlice

      public DonutChart addSlice(Slice slice)
      Adds a slice to this chart.
      Parameters:
      slice - the slice.
      Returns:
      this DonutChart object.
    • setAltDescription

      public DonutChart setAltDescription(String altDescription)
      Sets the alternate description of the chart, which a screen reader reads in a PDF/UA document, where the chart is a figure. The default lists the label and the percentage of each slice.
      Parameters:
      altDescription - the alternate description.
      Returns:
      this DonutChart object.
    • drawOn

      public float[] drawOn(Page page) throws Exception
      Draws this chart on the specified page.
      Specified by:
      drawOn in interface Drawable
      Parameters:
      page - the page to draw on.
      Returns:
      x and y coordinates of the bottom right corner of the outer circle of this chart. The slice labels can extend past it.
      Throws:
      Exception - if an input or output exception occurred.