Class CategoricalSeries
- Direct Known Subclasses:
FunnelSeries, PieSeries
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidRecords a zero baseline as the start of the entry animation.protected voidRecords the values currently on screen as the start of the next transition.voidcollectTableRows(List<String[]> rows) Adds this series' data to an accessible table, one{series, item, value}row per point.protected doubledisplayTotal(ChartContext ctx) The sum of the displayed values.protected doubledisplayValue(ChartContext ctx, int i) The value of partiin the current frame of an animation; hidden parts shrink to 0.formatTooltip(ChartContext ctx, ChartPoint p) The tooltip row for a point: the series or point name and its formatted value.intgetColor(int i) The colour of parti.getLabel(int i) The name of parti.intEntries this series contributes to the legend; a single series by default, one per slice for a pie.getLegendEntryName(int i) The name of legend entryi.intThe number of points along x, for a shared tooltip; -1 when not index aligned.doublegetTotal()The sum of the visible target values, for percentages.doublegetValue(int i) The value of parti.booleanTrue for series drawn against x and y axes; false for pies, treemaps and other series that fill the plot themselves.protected booleanisEntering(ChartContext ctx) True while the first appearance animation runs.booleanisLegendEntryVisible(int i) True if entryiis visible; a pie slice can be hidden on its own.booleanisShown(int i) True if partiis shown.protected doubleThe largest value a percentage is taken of: shown, positive and finite; 0 when none.voidpaintLegendEntrySymbol(Graphics g, int i, int x, int y, int size) Paints the swatch of legend entryi.protected doublepercentOf(int i, double maxPart, double scaledTotal) The percentage partiis of the shown parts, given the base fromlargestShown()andscaledShownTotal(); negative when the part has no share to print (hidden, NaN, negative or infinite).protected ChartPointpoint(ChartContext ctx, int i, float sx, float sy) A point describing partiat a screen position.protected doublescaledShownTotal(double maxPart) The total of the shown values, each divided bymaxPart.setColors(int... rgb) Fixes the colour of each part instead of using the theme palette.Replaces all parts.setValue(int i, double value) Changes the value of one part, animated.intsize()The number of parts.voidtoggleLegendEntry(int i) Toggles legend entryi.Methods inherited from class Series
attached, dataChanged, detached, formatValue, getChart, getColor, getName, getPoint, getSelectablePointCount, getValueFormatter, getVisibilityFraction, getXBounds, getXBoundsWithin, getYBounds, handleTap, hitTest, isGap, isPointCountFromLayout, isSecondaryAxis, isShowValues, isVisible, lerp, paint, paintLegendSymbol, repaintChart, setColor, setName, setSecondaryAxis, setShowValues, setValueFormatter, setVisible, transitionEnded
-
Constructor Details
-
CategoricalSeries
Creates an empty series.
Parameters
name: the series name
-
-
Method Details
-
isCartesian
public boolean isCartesian()Description copied from class:SeriesTrue for series drawn against x and y axes; false for pies, treemaps and other series that fill the plot themselves.- Specified by:
isCartesianin classSeries
-
setData
Replaces all parts.
Parameters
-
labels: the name of each part -
values: the value of each part, parallel to the labels
Returns
this series
-
-
setValue
Changes the value of one part, animated.
Parameters
-
i: the part index -
value: the new value
Returns
this series
-
-
setColors
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
The name of parti. -
getValue
public double getValue(int i) The value of parti. -
getColor
public int getColor(int i) The colour of parti. -
isShown
public boolean isShown(int i) True if partiis shown. -
displayValue
The value of part
iin 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
True while the first appearance animation runs.
Parameters
ctx: the paint context
Returns
true during the entry animation
-
displayTotal
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 oflargestShown()
Returns
the scaled total
-
percentOf
protected double percentOf(int i, double maxPart, double scaledTotal) The percentage part
iis of the shown parts, given the base fromlargestShown()andscaledShownTotal(); 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 bymaxPart
Returns
the percentage, or a negative number
-
-
captureTransitionStart
protected void captureTransitionStart()Description copied from class:SeriesRecords 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:
captureTransitionStartin classSeries
-
captureEntryStart
protected void captureEntryStart()Description copied from class:SeriesRecords a zero baseline as the start of the entry animation.- Overrides:
captureEntryStartin classSeries
-
getLegendEntryCount
public int getLegendEntryCount()Description copied from class:SeriesEntries this series contributes to the legend; a single series by default, one per slice for a pie.- Overrides:
getLegendEntryCountin classSeries
-
getLegendEntryName
Description copied from class:SeriesThe name of legend entryi.- Overrides:
getLegendEntryNamein classSeries
-
paintLegendEntrySymbol
Description copied from class:SeriesPaints the swatch of legend entryi.- Overrides:
paintLegendEntrySymbolin classSeries
-
isLegendEntryVisible
public boolean isLegendEntryVisible(int i) Description copied from class:SeriesTrue if entryiis visible; a pie slice can be hidden on its own.- Overrides:
isLegendEntryVisiblein classSeries
-
toggleLegendEntry
public void toggleLegendEntry(int i) Description copied from class:SeriesToggles legend entryi.- Overrides:
toggleLegendEntryin classSeries
-
getPointCount
public int getPointCount()Description copied from class:SeriesThe number of points along x, for a shared tooltip; -1 when not index aligned.- Overrides:
getPointCountin classSeries
-
formatTooltip
Description copied from class:SeriesThe 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:
formatTooltipin classSeries
-
-
point
A point describing part
iat 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
Description copied from class:SeriesAdds this series' data to an accessible table, one
{series, item, value}row per point. Used byChart.toTable()and the chart's accessibility text.Parameters
rows: the list to append rows to
- Overrides:
collectTableRowsin classSeries
-