Package limn.components.chart
Class BarChart
java.lang.Object
limn.scene.Widget
limn.components.chart.Chart
limn.components.chart.CartesianChart
limn.components.chart.BarChart
Bars, grouped or stacked, vertical or horizontal.
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
Constructors -
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 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, isHorizontal, isStacked, paintContent, pickAt, plotHeight, plotWidth, plotX, plotY, scale, setHorizontal, setStacked, stackBase, stackKeys, stackTotal, tooltipRows, valueAxis, valuePositionMethods inherited from class limn.components.chart.Chart
addSeries, animationDuration, background, categoryCount, clearSeries, contentBoxHeight, contentBoxWidth, contentLeft, contentTop, dataGeneration, drawnValue, elementProgress, ellipsize, hoveredPoint, isLegendInteractive, isTooltipEnabled, label, labels, labelSource, legendChanged, legendEntries, legendPosition, measure, onAttached, onHoverChanged, 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, valueFormat, withControlSizeMethods inherited from class limn.scene.Widget
acceptsTextInput, add, baselineOffset, baselineOffsetOf, caretRect, children, clipboard, clipsChildren, controlSize, cursor, declaredControlSize, declaredLayoutDirection, declaredLocale, focusArrivedByTraversal, height, hitTest, imageCursor, invalidate, invalidate, isEnabled, isFocusable, isFocused, isShowing, isVisible, layoutBox, layoutDirection, locale, localToSceneX, localToSceneY, markNeedsContainedLayout, markNeedsLayout, measure, moveChild, neutralBase, onCharTyped, onDetached, onFileDrop, onFocusGained, onFocusLost, onKeyEvent, onLayout, onPreedit, overlayPassesPointer, paintChildren, paintOutset, paintWidget, parent, remove, requestFocus, revealInView, scene, sceneToLocalX, sceneToLocalY, setControlSize, setCursor, setEnabled, setFocusable, setImageCursor, setInheritanceHost, setLayoutDirection, setLocale, setTooltip, setTooltip, setVisible, shapeText, textRuler, tooltip, width, x, y
-
Constructor Details
-
BarChart
public BarChart()
-
-
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
-
paintMarks
Description copied from class:CartesianChartPaints the marks inside the plot region; grid and axes are already down.- Specified by:
paintMarksin classCartesianChart
-
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
-
pointOf
Description copied from class:CartesianChartThe datum for one series at one category, anchored at that series' mark.- Specified by:
pointOfin classCartesianChart
-