Class CategoricalSeries

java.lang.Object
com.codename1.ui.chart.Series
com.codename1.ui.chart.series.CategoricalSeries
Direct Known Subclasses:
FunnelSeries, PieSeries

public abstract class CategoricalSeries extends Series

Base of series made of named parts that fill the plot: pie slices, funnel stages.

Each part gets its own legend entry and colour from the theme palette, and can be hidden on its own by tapping its legend entry; the others animate to fill the gap.

  • Constructor Details

    • CategoricalSeries

      protected CategoricalSeries(String name)

      Creates an empty series.

      Parameters
      • name: the series name
  • Method Details

    • isCartesian

      public boolean isCartesian()
      Description copied from class: Series
      True for series drawn against x and y axes; false for pies, treemaps and other series that fill the plot themselves.
      Specified by:
      isCartesian in class Series
    • setData

      public CategoricalSeries setData(String[] labels, double[] values)

      Replaces all parts.

      Parameters
      • labels: the name of each part

      • values: the value of each part, parallel to the labels

      Returns

      this series

    • setValue

      public CategoricalSeries setValue(int i, double value)

      Changes the value of one part, animated.

      Parameters
      • i: the part index

      • value: the new value

      Returns

      this series

    • setColors

      public CategoricalSeries setColors(int... rgb)

      Fixes the colour of each part instead of using the theme palette.

      Parameters
      • rgb: one colour per part
      Returns

      this series

    • size

      public int size()
      The number of parts.
    • getLabel

      public String getLabel(int i)
      The name of part i.
    • getValue

      public double getValue(int i)
      The value of part i.
    • getColor

      public int getColor(int i)
      The colour of part i.
    • isShown

      public boolean isShown(int i)
      True if part i is shown.
    • displayValue

      protected double displayValue(ChartContext ctx, int i)

      The value of part i in the current frame of an animation; hidden parts shrink to 0.

      Parameters
      • ctx: the paint context

      • i: the part index

      Returns

      the displayed value

    • isEntering

      protected boolean isEntering(ChartContext ctx)

      True while the first appearance animation runs.

      Parameters
      • ctx: the paint context
      Returns

      true during the entry animation

    • displayTotal

      protected double displayTotal(ChartContext ctx)

      The sum of the displayed values.

      Parameters
      • ctx: the paint context
      Returns

      the total

    • getTotal

      public double getTotal()
      The sum of the visible target values, for percentages.
    • largestShown

      protected double largestShown()

      The largest value a percentage is taken of: shown, positive and finite; 0 when none.

      Returns

      the largest shown value

    • scaledShownTotal

      protected double scaledShownTotal(double maxPart)

      The total of the shown values, each divided by maxPart.

      Parameters
      • maxPart: the value of largestShown()
      Returns

      the scaled total

    • percentOf

      protected double percentOf(int i, double maxPart, double scaledTotal)

      The percentage part i is of the shown parts, given the base from largestShown() and scaledShownTotal(); negative when the part has no share to print (hidden, NaN, negative or infinite).

      Parameters
      • i: the part index

      • maxPart: the largest shown value

      • scaledTotal: the total scaled by maxPart

      Returns

      the percentage, or a negative number

    • captureTransitionStart

      protected void captureTransitionStart()
      Description copied from class: Series
      Records the values currently on screen as the start of the next transition. Called by the chart before data changes; a subclass with animated data overrides it.
      Overrides:
      captureTransitionStart in class Series
    • captureEntryStart

      protected void captureEntryStart()
      Description copied from class: Series
      Records a zero baseline as the start of the entry animation.
      Overrides:
      captureEntryStart in class Series
    • getLegendEntryCount

      public int getLegendEntryCount()
      Description copied from class: Series
      Entries this series contributes to the legend; a single series by default, one per slice for a pie.
      Overrides:
      getLegendEntryCount in class Series
    • getLegendEntryName

      public String getLegendEntryName(int i)
      Description copied from class: Series
      The name of legend entry i.
      Overrides:
      getLegendEntryName in class Series
    • paintLegendEntrySymbol

      public void paintLegendEntrySymbol(Graphics g, int i, int x, int y, int size)
      Description copied from class: Series
      Paints the swatch of legend entry i.
      Overrides:
      paintLegendEntrySymbol in class Series
    • isLegendEntryVisible

      public boolean isLegendEntryVisible(int i)
      Description copied from class: Series
      True if entry i is visible; a pie slice can be hidden on its own.
      Overrides:
      isLegendEntryVisible in class Series
    • toggleLegendEntry

      public void toggleLegendEntry(int i)
      Description copied from class: Series
      Toggles legend entry i.
      Overrides:
      toggleLegendEntry in class Series
    • getPointCount

      public int getPointCount()
      Description copied from class: Series
      The number of points along x, for a shared tooltip; -1 when not index aligned.
      Overrides:
      getPointCount in class Series
    • formatTooltip

      public String formatTooltip(ChartContext ctx, ChartPoint p)
      Description copied from class: Series

      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: the last paint context

      • p: the point

      Returns

      one line of text

      Overrides:
      formatTooltip in class Series
    • point

      protected ChartPoint point(ChartContext ctx, int i, float sx, float sy)

      A point describing part i at a screen position.

      Parameters
      • ctx: the paint context

      • i: the part index

      • sx: absolute screen x of the part's anchor

      • sy: absolute screen y of the part's anchor

      Returns

      the point

    • collectTableRows

      public void collectTableRows(List<String[]> rows)
      Description copied from class: Series

      Adds this series' data to an accessible table, one {series, item, value} row per point. Used by Chart.toTable() and the chart's accessibility text.

      Parameters
      • rows: the list to append rows to
      Overrides:
      collectTableRows in class Series