Class LineChart
Everything about how a line looks belongs to its ChartSeries (width, marker
size, whether it is filled, whether it curves), because a chart normally mixes them: a
filled band for the range and a plain line for the actual. The chart-level setters here
write through to every series, present and future, as a shorthand for "all of them".
Double.NaN breaks the line. A gap is drawn as a gap, and a filled series
fills each run of real values separately rather than bridging the hole with a shape that
asserts data nobody has.
Unlike bars, the value axis does not begin at zero: a line encodes value as
position rather than as length, so it may zoom into the range that matters.
chart.valueAxis().setBeginAtZero(true) restores the zero baseline.
LineChart chart = new LineChart();
chart.setLabels("00", "04", "08", "12", "16", "20");
chart.addSeries(ChartSeries.of("Latency", 24, 21, 38, 42, 31, 26).setFilled(true));
chart.setSmooth(true);
-
Nested Class Summary
Nested classes/interfaces inherited from class limn.components.chart.Chart
Chart.LegendEntry, Chart.LegendPosition, Chart.TooltipMode -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionAn empty line chart: add labels and series before it has anything to draw. -
Method Summary
Modifier and TypeMethodDescriptionprotected floatA lit marker grows toHOVER_SCALEof its radius and is centred on the band, so it reaches that far outside it; the ring around it adds a border.static LineChartof(List<String> labels, ChartSeries... series) A line chart overlabels, with the given series.protected voidOne chart node, named by the title when there is one and carrying which way the value axis runs, with one toggleable series node per series in paint order: the body every chart with axes shares, declared here because the coverage ratchet counts a hook the class declares itself.protected voidonSeriesAdded(ChartSeries added) Called with a series that has just joined the chart, before anything is animated.protected booleanonSyntheticAction(long key, Accessible.Action action, Accessible.Argument arg) A toggle on a series node reaches the same path a click on its legend entry reaches, so a reader's toggle and a pointer's are one and the same to the chart and to the application, which is told nothing by either; refused when the legend is not interactive, when the series has no legend row for a pointer to have found, or when the key names no series.protected voidpaintMarks(Canvas canvas) Paints the marks inside the plot region; grid and axes are already down.protected intpickSeries(int category, float localX, float localY) Which series a pointer insidecategoryis reporting: the mark it is on if any, and otherwise the nearest one, so a click in the whitespace of a column still names a datum.protected ChartPointpointOf(int seriesIndex, int category) The datum for one series at one category, anchored at that series' mark.setArea(boolean value) Fills every series, and every series added later.setLineWidth(float points) Sets the stroke width of every series, and of every series added later.setPointRadius(float points) Sets the marker radius of every series, and of every series added later (0hides).setSmooth(boolean value) Curves every series, and every series added later.setTension(float value) Sets the curve strength of smoothed series, from0(straight segments) to about0.5(a Catmull-Rom spline through the points).floattension()How hard a smoothed line curves.Methods inherited from class limn.components.chart.CartesianChart
animationBaseline, bandCenter, bandSize, bandStart, categoryAt, categoryAxis, hoverRegion, isHorizontal, isStacked, paintContent, pickAt, plotHeight, plotWidth, plotX, plotY, setHorizontal, setStacked, stackBase, stackKeys, stackTotal, tooltipRows, valueAxis, valuePositionMethods inherited from class limn.components.chart.Chart
addSeries, animationDuration, background, categoryCount, clearSeries, clearTitle, contentBoxHeight, contentBoxWidth, contentLeft, contentTop, damageHoverInPlace, dataGeneration, drawnValue, elementProgress, ellipsize, handleUserChange, hoveredPoint, isLegendInteractive, isTooltipEnabled, label, labels, labelSource, legendChanged, legendEntries, legendEntryBounds, legendEntryCount, legendPosition, measure, onAttached, onHoverChanged, onLayout, onMeasure, onMouseEvent, onPaint, onPaintOverlay, onPointClick, onPointHover, palette, pointFor, progress, removeSeries, replayAnimation, series, series, seriesAlpha, seriesColor, seriesCount, setAnimationDuration, setAnimationEasing, setBackground, setLabels, setLabels, setLabels, setLegendInteractive, setLegendPosition, setPalette, setPreferredSize, setSeries, setTitle, setTitle, setTooltipEnabled, setTooltipFormat, setTooltipMode, setValueFormat, staggerFraction, stateFadeSeconds, title, titleSource, toggleLegendEntry, tokens, tooltipMode, tooltipRowColor, tooltipRowName, tooltipRowValue, tooltipTitle, updateRegions, valueFormatMethods inherited from class limn.scene.Widget
acceptsTextInput, accessibleLabelAccessKey, accessibleLabelTarget, accessibleLabelText, add, add, announceChange, backdropReach, baselineOffset, baselineOffsetOf, caretRect, children, clipboard, clipHeight, clipsChildren, clipWidth, clipX, clipY, controlSize, cursor, declaredControlSize, declaredLayoutDirection, declaredLocale, focusArrivedBackward, focusArrivedByTraversal, height, hitTest, hitTestChild, id, imageCursor, inheritanceHost, invalidate, invalidate, invalidateAccessible, isEnabled, isFocusable, isFocused, isRightToLeft, isSelfEnabled, isShowing, isVisible, isVisibleByItsOwnFlag, layoutBox, layoutDirection, locale, localToScene, localToSceneBounds, markNeedsContainedLayout, markNeedsLayout, markNeedsLayoutInPlace, maxHeight, maxWidth, measure, minHeight, minWidth, moveChild, moveChild, moveChild, neutralBase, notifyChange, notifyTextEdit, observeChanges, onAccessibilityAction, onAccessibilityChild, onAccessibilityChildAction, onAccessibilityChildIdentity, onCanEdit, onCharTyped, onDetached, onDragExit, onDragOver, onDragStart, onDrop, onEdit, onFocusGained, onFocusLost, onHitTest, onKeyEvent, onPreedit, overlayPassesPointer, paintChildren, paintOutset, paintsDecoration, paintsFromBackdrop, paintWidget, parent, remove, remove, requestFocus, requestFocus, revealInView, revealInView, runHandler, scene, sceneNanos, sceneToLocal, self, setAccessibleDescribedBy, setAccessibleDescription, setAccessibleDescription, setAccessibleIgnored, setAccessibleLabelledBy, setAccessibleName, setAccessibleName, setAccessibleRole, setControlSize, setCursor, setEnabled, setFocusable, setId, setImageCursor, setInheritanceHost, setLayoutDirection, setLocale, setMaxHeight, setMaxWidth, setMinHeight, setMinWidth, setPresentedElsewhere, setTooltip, setTooltip, setVisible, shapeText, textRuler, tooltip, tooltipSource, width, x, y
-
Constructor Details
-
LineChart
public LineChart()An empty line chart: add labels and series before it has anything to draw.
-
-
Method Details
-
of
A line chart overlabels, with the given series. -
setSmooth
Curves every series, and every series added later. SeeChartSeries.setSmooth(boolean). -
setArea
Fills every series, and every series added later. SeeChartSeries.setFilled(boolean). -
setLineWidth
Sets the stroke width of every series, and of every series added later. -
setPointRadius
Sets the marker radius of every series, and of every series added later (0hides). -
tension
public float tension()How hard a smoothed line curves. -
setTension
Sets the curve strength of smoothed series, from0(straight segments) to about0.5(a Catmull-Rom spline through the points). Default0.4. Higher values overshoot past the data. -
onSeriesAdded
Description copied from class:ChartCalled with a series that has just joined the chart, before anything is animated. Charts with per-series defaults of their own apply them here, so a series added after the default was set is styled like the ones that were already there.- Overrides:
onSeriesAddedin classChart<LineChart>
-
paintMarks
Description copied from class:CartesianChartPaints the marks inside the plot region; grid and axes are already down.- Specified by:
paintMarksin classCartesianChart<LineChart>
-
hoverMarkMargin
protected float hoverMarkMargin()A lit marker grows toHOVER_SCALEof its radius and is centred on the band, so it reaches that far outside it; the ring around it adds a border.- Overrides:
hoverMarkMarginin classCartesianChart<LineChart>- Returns:
- a margin in logical points
-
pickSeries
protected int pickSeries(int category, float localX, float localY) Description copied from class:CartesianChartWhich series a pointer insidecategoryis reporting: the mark it is on if any, and otherwise the nearest one, so a click in the whitespace of a column still names a datum.-1when the category has nothing visible in it.- Specified by:
pickSeriesin classCartesianChart<LineChart>
-
pointOf
Description copied from class:CartesianChartThe datum for one series at one category, anchored at that series' mark.- Specified by:
pointOfin classCartesianChart<LineChart>
-
onAccessibility
One chart node, named by the title when there is one and carrying which way the value axis runs, with one toggleable series node per series in paint order: the body every chart with axes shares, declared here because the coverage ratchet counts a hook the class declares itself.Every series is a node because every series is drawn, legend or no legend. A series' box is its legend row, the rectangle a click toggles it on and the one per-series geometry that stands still: the line's own points live in buffers that hold one series at a time, are overwritten by the next series painted, and are keyed on the animation's progress, so a box over them would be an alias that moved on every frame of an entry nobody is touching. A series with no legend row keeps the chart's box. The toggle is the model's visibility bit and never the fade a hidden line goes out through, so those frames damage the chart and publish nothing; smoothing, filling, the stroke width, the marker radius and the tension are style, and are nowhere in the tree. Nothing is generated from the axes or the values.
- Overrides:
onAccessibilityin classWidget<LineChart>- Parameters:
a- the node being described; write into it, and never keep it
-
onSyntheticAction
A toggle on a series node reaches the same path a click on its legend entry reaches, so a reader's toggle and a pointer's are one and the same to the chart and to the application, which is told nothing by either; refused when the legend is not interactive, when the series has no legend row for a pointer to have found, or when the key names no series.- Overrides:
onSyntheticActionin classWidget<LineChart>- Parameters:
key- the key this widget gave that child when it declared itaction- what was askedarg- the argument, orAccessible.Argument.NONE- Returns:
- whether this widget did it
-