AnyLogic
Expand
Font size
All Implemented Interfaces:
com.anylogic.engine.internal.Child, Locatable2D, AggregatableAnimationElement, HasLevel, LevelElement, SVGElement, Serializable, Cloneable

public class BarChart
extends Chart1D
The chart that displays a number of data items as bars with dimension proportional to their values (which can be negative). The legend values of data items are set to [data item name]: [data item value].
The orientation of the bars may be arbitrary (NORTH, SOUTH, EAST, WEST). The bars scale type may be SCALE_AUTO, then bars are fitted into the best grid, or SCALE_FIXED, when the user specifies the minimum and maximum. The thickness of bars can be controlled. The chart may have scale text labels and a grid.
Author:
AnyLogic North America, LLC https://anylogic.com
See Also:
Serialized Form

Nested Class Summary

Nested classes/interfaces inherited from class com.anylogic.engine.analysis.Chart

Chart.Direction, Chart.GridPosition, Chart.InterpolationType, Chart.PointStyle, Chart.ScaleType, Chart.TimeWindowMovementType

Nested classes/interfaces inherited from class com.anylogic.engine.presentation.ShapeControl

ShapeControl.ValueType

Field Summary

Fields inherited from class com.anylogic.engine.presentation.ShapeControl

TYPE_DOUBLE, TYPE_INT, TYPE_STRING

Fields inherited from class com.anylogic.engine.presentation.Shape

UNKNOWN_NAME

Constructor Summary

ConstructorDescription
BarChart(Presentable p, boolean ispublic, double x, double y, double width, double height, Color fillColor, Color lineColor, double picOffsetX, double picOffsetY, double picWidth, double picHeight, Color picBackgoundColor, Color picBorderColor, Color legendTextColor, double legendSize, Chart.Direction legendPos, Chart.Direction barDirection, Chart.ScaleType scaleType, double minimum, double maximum, double relativeBarWidth, Chart.GridPosition gridPosition, Color gridLineColor, Color gridTextColor, List<DataItem> dataItems, List<String> titles, List<Color> colors)
Creates a persistent BarChart.

Method Summary

Modifier and TypeMethodDescription
voidaddDataItem(DataItem di, String title, Color color)
Adds a DataItem to the chart.
voidpostSVGShapeSpecificAttributes(List<String> att, List<String> val, boolean publicOnly)
Posts general properties specific to a particular shape class.
voidrefresh()
Causes the chart to refresh its picture and legend based on the newest data values.
voidsetFixedScale(double minimum, double maximum)
Sets fixed scale for the chart

Methods inherited from class com.anylogic.engine.analysis.Chart1D

addDataItem, getColor, setColor

Methods inherited from class com.anylogic.engine.presentation.ShapeControl

contains, executeAction, getHeight, getPresentable, getWidth, isEnabled, randomPointInside, restoreOwner, setEnabled, setHeight, setValueToDefault, setWidth

Methods inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Methods inherited from interface com.anylogic.engine.markup.AggregatableAnimationElement

initializeInternal, postInitialize

Constructor Details

BarChart

public BarChart(Presentable p,
 boolean ispublic,
 double x,
 double y,
 double width,
 double height,
 Color fillColor,
 Color lineColor,
 double picOffsetX,
 double picOffsetY,
 double picWidth,
 double picHeight,
 Color picBackgoundColor,
 Color picBorderColor,
 Color legendTextColor,
 double legendSize,
 Chart.Direction legendPos,
 Chart.Direction barDirection,
 Chart.ScaleType scaleType,
 double minimum,
 double maximum,
 double relativeBarWidth,
 Chart.GridPosition gridPosition,
 Color gridLineColor,
 Color gridTextColor,
 List<DataItem> dataItems,
 List<String> titles,
 List<Color> colors)
Creates a persistent BarChart. If the collection of DataItem objects and a collection of their colors are null, new empty collections are created.
Parameters:
p - the presentable object owning this chart
ispublic - if true, the chart is visible on container's presentation
x - the x coordinate of the chart
y - the y coordinate of the chart
width - the width of the whole chart
height - the height of the whole chart
fillColor - the background color of the whole chart
lineColor - the line border color of the whole chart
picOffsetX - the x offset of the picture from the top left corner of the picture area
picOffsetY - the y offset of the picture from the top left corner of the picture area
picWidth - the width of the picture
picHeight - the height of the picture
picBackgoundColor - the background color of the picture, null for none (transparent)
picBorderColor - the border color of the picture, null for no border
legendTextColor - the color of the legend text
legendSize - the size of the legend area: width if legendPos is EAST or WEST, height if NORTH or SOUTH
legendPos - the legend position (NONE, SOUTH, NORTH, EAST, WEST)
barDirection - the orientation of bars (SOUTH, NORTH, EAST, WEST)
scaleType - the scale type (SCALE_AUTO or SCALE_FIXED)
minimum - the minimum scale value (for SCALE_FIXED only)
maximum - the maximum scale value (for SCALE_FIXED only)
relativeBarWidth - the thickness of the bars (1 - maximum, 0.5 - half, etc.)
gridPosition - the position of the scale text labels (GRID_NONE for none, GRID_DEFAULT or GRID_OPPOSITE)
gridLineColor - the color of grid lines, which then becomes semitransparent, null for no lines
gridTextColor - the color of scale text labels, null for no text labels
dataItems - the collection of data items to be displayed, or null
titles - the collection of data item titles, or null
colors - the collection of data item colors, or null

Method Details

addDataItem

public void addDataItem(DataItem di,
 String title,
 Color color)
Adds a DataItem to the chart.
Overrides:
addDataItem in class Chart1D
Parameters:
di - the data item to add
title - the data item title
color - the color that will be associated with this data item

setFixedScale

public void setFixedScale(double minimum,
 double maximum)
Sets fixed scale for the chart
Parameters:
minimum - minimum of chart axis scale
maximum - maximum of chart axis scale

refresh

public void refresh()
Causes the chart to refresh its picture and legend based on the newest data values.
Overrides:
refresh in class Chart<DataItem>

postSVGShapeSpecificAttributes

public void postSVGShapeSpecificAttributes(List<String> att,
 List<String> val,
 boolean publicOnly)
Description copied from class: Shape
Posts general properties specific to a particular shape class. Is triggered by SVG_DIRTY_SHAPE flag. Made public for occasional posting of additional SVG properties from outside engine (e.g. from libraries)
Overrides:
postSVGShapeSpecificAttributes in class Chart<DataItem>
Parameters:
att - attribute names
val - attribute values
publicOnly - TODO