de.erichseifert.gral.plots
Class BarPlot
- java.lang.Object
-
- All Implemented Interfaces:
- DataListener, Container, Drawable, Navigable, AxisListener, Plot, java.io.Serializable, java.lang.Iterable<Drawable>
public class BarPlot extends XYPlot
Class that displays data in a bar plot.
To create a new
BarPlotsimply create a new instance using one or more data sources. Example:DataTable data = new DataTable(Integer.class, Double.class); data.add(2010, -5.00); data.add(2011, 3.25); data.add(2012, -0.50); data.add(2012, 4.00); BarPlot plot = new BarPlot(data);
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classBarPlot.BarPlotLegendA legend implementation for bar plots that displays all values of the data source as items.static classBarPlot.BarRendererClass that renders a bar in a bar plot.-
Nested classes/interfaces inherited from class de.erichseifert.gral.plots.XYPlot
XYPlot.XYLegend, XYPlot.XYNavigationDirection, XYPlot.XYPlotArea2D, XYPlot.XYPlotNavigator
-
-
Constructor Summary
Constructors Constructor and Description BarPlot(DataSource... data)Creates a new instance and initializes it with the specified data sources.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidadd(int index, DataSource source, boolean visible)Inserts the specified data series to the plot at a specified position.voidautoscaleAxis(java.lang.String axisName)Tries to automatically set the ranges of the axes specified by the name if it is set to auto-scale.doublegetBarHeightMin()Returns the minimum height of the bars in view units (e.g.doublegetBarWidth()Returns the width of the bars in axis coordinates.booleanisPaintAllBars()Returns whether all bars are filled as a whole, or if each bar is filled independently.voidsetBarHeightMin(double barHeightMin)Sets the minimum height of the bars in view units (e.g.voidsetBarWidth(double barWidth)Sets the width of the bars in axis coordinates.voidsetPaintAllBars(boolean paintAllBars)Sets whether all bars will be filled as a whole, or if each bar will be filled independently.-
Methods inherited from class de.erichseifert.gral.plots.XYPlot
addPointRenderer, draw, getAreaRenderers, getLineRenderers, getNavigator, getPointRenderers, rangeChanged, removePointRenderer, setAreaRenderers, setAreaRenderers, setAxisRenderer, setLineRenderers, setLineRenderers, setPointRenderers, setPointRenderers
-
Methods inherited from class de.erichseifert.gral.plots.AbstractPlot
add, add, clear, contains, dataAdded, dataRemoved, dataUpdated, get, getAxesNames, getAxis, getAxisRenderer, getBackground, getBorderColor, getBorderStroke, getData, getFont, getLegend, getLegendDistance, getLegendLocation, getMapping, getPlotArea, getTitle, getVisibleData, isLegendVisible, isVisible, layout, remove, removeAxis, setAxis, setBackground, setBorderColor, setBorderStroke, setFont, setLegendDistance, setLegendLocation, setLegendVisible, setMapping, setVisible
-
Methods inherited from class de.erichseifert.gral.graphics.DrawableContainer
add, add, contains, getConstraints, getDrawables, getDrawablesAt, getInsets, getLayout, getPreferredSize, iterator, remove, setBounds, setBounds, setInsets, setLayout, size
-
Methods inherited from class de.erichseifert.gral.graphics.AbstractDrawable
getBounds, getHeight, getWidth, getX, getY, setPosition
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.erichseifert.gral.graphics.Drawable
getBounds, getHeight, getPreferredSize, getWidth, getX, getY, setBounds, setBounds, setPosition
-
Methods inherited from interface de.erichseifert.gral.graphics.Container
add, add, contains, getBounds, getConstraints, getDrawables, getDrawablesAt, getInsets, getLayout, remove, setBounds, setInsets, setLayout, size
-
-
-
-
Constructor Detail
-
BarPlot
public BarPlot(DataSource... data)
Creates a new instance and initializes it with the specified data sources.- Parameters:
data- Data to be displayed.
-
-
Method Detail
-
autoscaleAxis
public void autoscaleAxis(java.lang.String axisName)
Description copied from class:AbstractPlotTries to automatically set the ranges of the axes specified by the name if it is set to auto-scale.- Specified by:
autoscaleAxisin interfacePlot- Overrides:
autoscaleAxisin classAbstractPlot- Parameters:
axisName- Name of the axis that should be scaled.- See Also:
Axis.setAutoscaled(boolean)
-
add
public void add(int index, DataSource source, boolean visible)Description copied from class:AbstractPlotInserts the specified data series to the plot at a specified position.
-
getBarWidth
public double getBarWidth()
Returns the width of the bars in axis coordinates.- Returns:
- Width of the bars in axis coordinates.
-
setBarWidth
public void setBarWidth(double barWidth)
Sets the width of the bars in axis coordinates.- Parameters:
barWidth- Width of the bars in axis coordinates.
-
getBarHeightMin
public double getBarHeightMin()
Returns the minimum height of the bars in view units (e.g. pixels on screen).- Returns:
- Minimum height of the bars in view units.
-
setBarHeightMin
public void setBarHeightMin(double barHeightMin)
Sets the minimum height of the bars in view units (e.g. pixels on screen).- Parameters:
barHeightMin- Minimum height of the bars in view units.
-
isPaintAllBars
public boolean isPaintAllBars()
Returns whether all bars are filled as a whole, or if each bar is filled independently.- Returns:
trueif all bars are filled as a whole, orfalseif each bar is filled independently.
-
setPaintAllBars
public void setPaintAllBars(boolean paintAllBars)
Sets whether all bars will be filled as a whole, or if each bar will be filled independently.- Parameters:
paintAllBars-trueto fill all bars as a whole, orfalseto fill each bar independently.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG