Class BarChart
Series stand side by side in each category by default. CartesianChart.setStacked(boolean)
accumulates them instead; series that name the same stack key share a column, and different keys stand side by side, so a chart can show
two stacks per category. Negative values stack downward on their own side of zero.
The value axis begins at zero: the length of a bar is the value it stands for, and an axis that starts anywhere else draws a ratio the data does not have. It can be overridden; it should not be.
BarChart chart = new BarChart();
chart.setLabels("Q1", "Q2", "Q3", "Q4");
chart.addSeries(ChartSeries.of("Direct", 120, 145, 132, 168));
chart.addSeries(ChartSeries.of("Partner", 80, 92, 105, 99));
chart.setStacked(true);
-
Nested Class Summary
Nested classes/interfaces inherited from class limn.components.chart.Chart
Chart.LegendEntry, Chart.LegendPosition, Chart.TooltipMode -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionBarChart()An empty bar chart: add labels and series before it has anything to draw. -
Method Summary
Modifier and TypeMethodDescriptionfloatThe fraction of each category slot left empty, split between its two sides.floatCorner radius of a bar's outer end, in logical points.static BarChartof(List<String> labels, ChartSeries... series) A bar chart overlabels, with the given series.protected voidOne chart node, named by the title when there is one and carrying which way the bars' 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 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.floatPoints of surface between two bars of the same category.setBarPadding(float fraction) Sets how much of each category slot is empty space, as a fraction in[0, 0.9](default0.22).setBarRadius(float value) Rounds the outer end of every bar; the end standing on the baseline stays square, so the bar still reads as anchored to zero rather than floating.setSeriesGap(float points) Sets the gap between grouped bars, in logical points.protected floatBars wipe in from the first category rather than all appearing at once.Methods inherited from class limn.components.chart.CartesianChart
animationBaseline, bandCenter, bandSize, bandStart, categoryAt, categoryAxis, hoverMarkMargin, 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, onSeriesAdded, 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, 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
-
BarChart
public BarChart()An empty bar chart: add labels and series before it has anything to draw.
-
-
Method Details
-
of
A bar chart overlabels, with the given series. -
barRadius
public float barRadius()Corner radius of a bar's outer end, in logical points. -
setBarRadius
Rounds the outer end of every bar; the end standing on the baseline stays square, so the bar still reads as anchored to zero rather than floating. -
barPadding
public float barPadding()The fraction of each category slot left empty, split between its two sides. -
setBarPadding
Sets how much of each category slot is empty space, as a fraction in[0, 0.9](default0.22).0makes a histogram, where bars touch. -
seriesGap
public float seriesGap()Points of surface between two bars of the same category. -
setSeriesGap
Sets the gap between grouped bars, in logical points. -
staggerFraction
protected float staggerFraction()Bars wipe in from the first category rather than all appearing at once.- Overrides:
staggerFractionin classChart<BarChart>
-
paintMarks
Description copied from class:CartesianChartPaints the marks inside the plot region; grid and axes are already down.- Specified by:
paintMarksin classCartesianChart<BarChart>
-
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<BarChart>
-
pointOf
Description copied from class:CartesianChartThe datum for one series at one category, anchored at that series' mark.- Specified by:
pointOfin classCartesianChart<BarChart>
-
onAccessibility
One chart node, named by the title when there is one and carrying which way the bars' 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: unlike a donut, a bar chart with one series and no legend still has that series on screen. A series' box is the legend entry a click toggles it on, the same rectangle the pointer is tested against, and never the union of its bars, which folds the entry animation in and would move on every frame of it; a series with no legend row keeps the chart's box, which is the honest answer to where it is. Its toggle state is the model's visibility bit and never the fade, so the frames of a fade damage the chart and publish nothing.
- Overrides:
onAccessibilityin classWidget<BarChart>- 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<BarChart>- 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
-