Class Series
- Direct Known Subclasses:
CategoricalSeries, GaugeSeries, HeatmapSeries, HierarchySeries, RadarSeries, SankeySeries, XYSeries
One data series. A series owns its data, its colour and how it paints itself; there is no separate renderer object to keep in step with it.
Changing data through a series' own methods animates the chart from the old values to
the new ones. Batch several changes inside Chart.update(Runnable) to animate them as
one transition.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidattached()Called by the chart when this series is added to it, and again when the chart comes back on screen (itsinitComponent); a series may be told more than once.protected 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 voidTells the chart this series' data changed, which animates the new values in.protected voiddetached()Called by the chart when this series is removed from it, or the chart leaves the screen (itsdeinitialize); a series may be told more than once.formatTooltip(ChartContext ctx, ChartPoint p) The tooltip row for a point: the series or point name and its formatted value.formatValue(ChartContext ctx, double value) Formats a value for a label or tooltip.getChart()The chart this series is in, or null.intgetColor()The explicit colour, or the theme colour for this series' position.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.getName()The legend name.getPoint(ChartContext ctx, int index) The point atindexfor a shared tooltip, or null.intThe number of points along x, for a shared tooltip; -1 when not index aligned.intThe number of pointsChart.setSelectionand arrow-key stepping can reach by index.Formatter for value labels and the tooltip, or null to use the value axis'.protected floatThe current shown fraction, 0 hidden to 1 shown, animated while the user toggles it.double[]The extent of the data along x,{min, max}, or null when empty or not cartesian.double[]getXBoundsWithin(double maxX) The extent along x of the data at or belowmaxX,{min, max}, or null when none is.double[]The extent of the data along y,{min, max}, or null when empty or not cartesian.booleanCalled when a point of this series is tapped, before the chart selects it.hitTest(ChartContext ctx, int x, int y, int radius) Finds the data point nearest a screen position.abstract booleanTrue for series drawn against x and y axes; false for pies, treemaps and other series that fill the plot themselves.protected static booleanisGap(double v) True for a value that cannot be plotted: NaN or either infinity.booleanisLegendEntryVisible(int i) True if entryiis visible; a pie slice can be hidden on its own.protected booleanTrue whengetPointCount()counts points a paint laid out (treemap, sunburst, Sankey) rather than the model's points, so an index past it may exist after the next paint.booleanTrue when the series is measured against the right hand value axis.booleanTrue when value labels are drawn next to the data.booleanFalse while the user has hidden it from the legend or the app hid it.protected static doublelerp(double a, double b, double t) Interpolates for transitions; a start that is a gap (NaN or infinite) means the value appears without a tween, since every in-between value of an infinite start is NaN or infinite and the point would vanish for the whole transition.abstract voidpaint(ChartContext ctx) Paints the series.voidpaintLegendEntrySymbol(Graphics g, int i, int x, int y, int size) Paints the swatch of legend entryi.voidpaintLegendSymbol(Graphics g, int x, int y, int size) Paints the legend swatch.protected voidRepaints without a transition.setColor(int rgb) Fixes the series colour instead of taking it from the theme palette.Renames the series.setSecondaryAxis(boolean secondaryAxis) Plots the series against the secondary (right) value axis.setShowValues(boolean showValues) Draws value labels on the data.setValueFormatter(ValueFormatter valueFormatter) Sets how values print in labels and tooltips.setVisible(boolean visible) Shows or hides the series with an animated transition.voidtoggleLegendEntry(int i) Toggles legend entryi.protected voidCalled by the chart when a transition has finished, so a subclass can drop the start values it captured; a later change that forgot to snapshot then shows its new values instead of replaying a transition from long gone data.
-
Constructor Details
-
Series
Creates a named series.
Parameters
name: shown in the legend and the tooltip
-
-
Method Details
-
getName
The legend name. -
setName
-
getColor
public int getColor()The explicit colour, or the theme colour for this series' position. -
setColor
Fixes the series colour instead of taking it from the theme palette. -
isVisible
public boolean isVisible()False while the user has hidden it from the legend or the app hid it. -
setVisible
Shows or hides the series with an animated transition. -
isSecondaryAxis
public boolean isSecondaryAxis()True when the series is measured against the right hand value axis. -
setSecondaryAxis
Plots the series against the secondary (right) value axis. -
isShowValues
public boolean isShowValues()True when value labels are drawn next to the data. Labels that would collide are left out rather than drawn over each other. -
setShowValues
Draws value labels on the data. -
getValueFormatter
Formatter for value labels and the tooltip, or null to use the value axis'. -
setValueFormatter
Sets how values print in labels and tooltips. -
getChart
The chart this series is in, or null. -
isCartesian
public abstract boolean isCartesian()True for series drawn against x and y axes; false for pies, treemaps and other series that fill the plot themselves. -
getXBounds
public double[] getXBounds()The extent of the data along x,{min, max}, or null when empty or not cartesian. -
getXBoundsWithin
public double[] getXBoundsWithin(double maxX) The extent along x of the data at or below
maxX,{min, max}, or null when none is. A category axis with no labels asks for this to leave a far outlier out of its bands.Parameters
maxX: the largest x that counts
Returns
the bounds of the points that count, or null
-
getYBounds
public double[] getYBounds()The extent of the data along y,{min, max}, or null when empty or not cartesian. -
paint
Paints the series.
Parameters
ctx: the current frame: graphics, plot area, axes and animation progress
-
hitTest
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
-
-
getPointCount
public int getPointCount()The number of points along x, for a shared tooltip; -1 when not index aligned. -
getSelectablePointCount
public int getSelectablePointCount()The number of pointsChart.setSelectionand arrow-key stepping can reach by index. The same asgetPointCount(), except for a series whose points are not index aligned with other series (scatter), which still has its own points to select. -
isPointCountFromLayout
protected boolean isPointCountFromLayout()True whengetPointCount()counts points a paint laid out (treemap, sunburst, Sankey) rather than the model's points, so an index past it may exist after the next paint. -
getPoint
The point atindexfor a shared tooltip, or null. -
paintLegendSymbol
Paints the legend swatch.
Parameters
-
g: graphics -
x: swatch left -
y: swatch top -
size: swatch size
-
-
getLegendEntryCount
public int getLegendEntryCount()Entries this series contributes to the legend; a single series by default, one per slice for a pie. -
getLegendEntryName
The name of legend entryi. -
paintLegendEntrySymbol
Paints the swatch of legend entryi. -
isLegendEntryVisible
public boolean isLegendEntryVisible(int i) True if entryiis visible; a pie slice can be hidden on its own. -
toggleLegendEntry
public void toggleLegendEntry(int i) Toggles legend entryi. -
captureTransitionStart
protected void captureTransitionStart()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. -
captureEntryStart
protected void captureEntryStart()Records a zero baseline as the start of the entry animation. -
transitionEnded
protected void transitionEnded()Called by the chart when a transition has finished, so a subclass can drop the start values it captured; a later change that forgot to snapshot then shows its new values instead of replaying a transition from long gone data. -
formatValue
Formats a value for a label or tooltip. -
formatTooltip
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
-
-
collectTableRows
-
handleTap
Called when a point of this series is tapped, before the chart selects it. A series that navigates on tap (drilling into a treemap node) returns true to stop the selection.
Parameters
p: the tapped point
Returns
true if the tap was consumed
-
attached
protected void attached()Called by the chart when this series is added to it, and again when the chart comes back on screen (itsinitComponent); a series may be told more than once. A series that listens to a model outliving it (aTreeNodetree) registers here, so the model does not keep a discarded chart reachable: a chart taken off screen, or a series removed from its chart, stops listening. -
detached
protected void detached()Called by the chart when this series is removed from it, or the chart leaves the screen (itsdeinitialize); a series may be told more than once. Undoesattached(). -
dataChanged
protected void dataChanged()Tells the chart this series' data changed, which animates the new values in. -
repaintChart
protected void repaintChart()Repaints without a transition. -
getVisibilityFraction
protected float getVisibilityFraction()The current shown fraction, 0 hidden to 1 shown, animated while the user toggles it. -
isGap
protected static boolean isGap(double v) True for a value that cannot be plotted: NaN or either infinity. Such a point is a gap, drawn as nothing and kept out of every axis bound. -
lerp
protected static double lerp(double a, double b, double t) Interpolates for transitions; a start that is a gap (NaN or infinite) means the value appears without a tween, since every in-between value of an infinite start is NaN or infinite and the point would vanish for the whole transition.
-