APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javafx.scene.chart

public Class StackedBarChart<X, Y>

extends XYChart<X, Y>
Class Inheritance
Type Parameters
<X>
the X axis value type
<Y>
the Y axis value type
Imports
java.util.ArrayList, .Collections, .HashMap, .Iterator, .List, .Map, javafx.animation.FadeTransition, .Interpolator, .KeyFrame, .KeyValue, .ParallelTransition, .Timeline, javafx.beans.NamedArg, javafx.beans.property.DoubleProperty, javafx.collections.FXCollections, .ListChangeListener, .ObservableList, javafx.css.CssMetaData, .PseudoClass, .Styleable, .StyleableDoubleProperty, .StyleableProperty, javafx.css.converter.SizeConverter, javafx.geometry.Orientation, javafx.scene.AccessibleRole, .Node, javafx.scene.layout.StackPane, javafx.util.Duration, com.sun.javafx.charts.Legend.LegendItem

StackedBarChart is a variation of BarChart that plots bars indicating data values for a category. The bars can be vertical or horizontal depending on which axis is a category axis. The bar for each series is stacked on top of the previous series.
Since
JavaFX 2.1

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private ListChangeListener<String>
private CategoryAxis
private DoubleProperty
categoryGap

The gap to leave between bars in separate categories

private static final PseudoClass
HORIZONTAL_PSEUDOCLASS_STATE

Pseudoclass indicating this is a horizontal chart.

private final Orientation
private ParallelTransition
private Map<XYChart.Series<X, Y>, Map<String, List<XYChart.Data<X, Y>>>>
private ValueAxis<T extends Number>
private static final PseudoClass
VERTICAL_PSEUDOCLASS_STATE

Pseudoclass indicating this is a vertical chart.

Inherited from javafx.scene.chart.XYChart:
DEFAULT_COLORseriesColorMap

Constructor Summary

AccessConstructor and Description
public
StackedBarChart(Axis<X>
The x axis to use
xAxis
,
Axis<Y>
The y axis to use
yAxis
)

Construct a new StackedBarChart with the given axis.

public
StackedBarChart(Axis<X>
The x axis to use
xAxis
,
Axis<Y>
The y axis to use
yAxis
,
ObservableList<XYChart.Series<X, Y>>
The data to use, this is the actual list used so any changes to it will be reflected in the chart
data
)

Construct a new StackedBarChart with the given axis and data.

public
StackedBarChart(Axis<X>
The x axis to use
xAxis
,
Axis<Y>
The y axis to use
yAxis
,
ObservableList<XYChart.Series<X, Y>>
The data to use, this is the actual list used so any changes to it will be reflected in the chart
data
,
double
The gap to leave between bars in separate categories
categoryGap
)

Construct a new StackedBarChart with the given axis and data.

Method Summary

Modifier and TypeMethod and Description
private void
animateDataAdd(XYChart.Data<X, Y> item, Node bar)

public DoubleProperty
private Node
createBar(XYChart.Series<X, Y> series, int seriesIndex, final XYChart.Data<X, Y> item, int itemIndex)

private Timeline
createDataRemoveTimeline(XYChart.Data<X, Y> item, final Node bar, final XYChart.Series<X, Y> series)

pack-priv Legend.LegendItem
createLegendItemForSeries(XYChart.Series<X, Y> series, int seriesIndex)

Overrides javafx.scene.chart.XYChart.createLegendItemForSeries.

Called by the updateLegend for each series in the chart in order to create new legend item

protected void
dataItemAdded(XYChart.Series<X, Y> series, int itemIndex, XYChart.Data<X, Y> item)

Implements abstract javafx.scene.chart.XYChart.dataItemAdded.

Called when a data item has been added to a series.

protected void
dataItemChanged(XYChart.Data<X, Y> item)

Implements abstract javafx.scene.chart.XYChart.dataItemChanged.

Called when a data item has changed, ie its xValue, yValue or extraValue has changed.

protected void
dataItemRemoved(final XYChart.Data<X, Y> item, final XYChart.Series<X, Y> series)

Implements abstract javafx.scene.chart.XYChart.dataItemRemoved.

Called when a data item has been removed from data model but it is still visible on the chart.

public double
public static List<CssMetaData<? extends Styleable, ?>>

Returns:

the CssMetaData
getClassCssMetaData
()

Hides javafx.scene.chart.XYChart.getClassCssMetaData.

Gets the CssMetaData associated with this class, which may include the CssMetaData of its superclasses.

public List<CssMetaData<? extends Styleable, ?>>
getCssMetaData()

Overrides javafx.scene.chart.XYChart.getCssMetaData.

Implements javafx.css.Styleable.getCssMetaData.

This method should delegate to Node#getClassCssMetaData() so that a Node's CssMetaData can be accessed without the need for reflection.

private List<XYChart.Data<X, Y>>
getDataItem(XYChart.Series<X, Y> series, String category)

protected void
layoutPlotChildren()

Implements abstract javafx.scene.chart.XYChart.layoutPlotChildren.

Called to update and layout the plot children.

private void
processDataRemove(final XYChart.Series<X, Y> series, final XYChart.Data<X, Y> item)

protected void
seriesAdded(XYChart.Series<X, Y> series, int seriesIndex)

Implements abstract javafx.scene.chart.XYChart.seriesAdded.

A series has been added to the charts data model.

pack-priv void
seriesBeingRemovedIsAdded(XYChart.Series<X, Y> series)

Overrides javafx.scene.chart.XYChart.seriesBeingRemovedIsAdded.

This method is called when there is an attempt to add series that was set to be removed, and the removal might not have completed.

protected void
seriesChanged(ListChangeListener.Change<? extends XYChart.Series<X, Y>> c)

Overrides javafx.scene.chart.XYChart.seriesChanged.

Called when each atomic change is made to the list of series for this chart

protected void
seriesRemoved(final XYChart.Series<X, Y> series)

Implements abstract javafx.scene.chart.XYChart.seriesRemoved.

A series has been removed from the data model but it is still visible on the chart.

public void
setCategoryGap(double value)

protected void
updateAxisRange()

Overrides javafx.scene.chart.XYChart.updateAxisRange.

This is called when the range has been invalidated and we need to update it.

private void
updateMap(XYChart.Series<X, Y> series, XYChart.Data<X, Y> item)

Inherited from javafx.scene.chart.XYChart:
alternativeColumnFillVisiblePropertyalternativeRowFillVisiblePropertycreateSeriesRemoveTimeLinecurrentDisplayedExtraValuePropertycurrentDisplayedXValuePropertycurrentDisplayedYValuePropertydataBeingRemovedIsAddeddataPropertygetCurrentDisplayedExtraValuegetCurrentDisplayedXValuegetCurrentDisplayedYValuegetDatagetDataSizegetDisplayedDataIteratorgetDisplayedSeriesIteratorgetPlotChildrengetSeriesIndexgetSeriesSizegetVerticalGridLinesVisiblegetXAxisgetYAxishorizontalGridLinesVisiblePropertyhorizontalZeroLineVisiblePropertyisAlternativeColumnFillVisibleisAlternativeRowFillVisibleisHorizontalGridLinesVisibleisHorizontalZeroLineVisibleisVerticalZeroLineVisiblelayoutChartChildrenremoveDataItemFromDisplayremoveSeriesFromDisplaysetAlternativeColumnFillVisiblesetAlternativeRowFillVisiblesetCurrentDisplayedExtraValuesetCurrentDisplayedXValuesetCurrentDisplayedYValuesetDatasetHorizontalGridLinesVisiblesetHorizontalZeroLineVisiblesetSuppressAnimationsetVerticalGridLinesVisiblesetVerticalZeroLineVisibleshouldAnimateupdateLegendupdateSymbolFocusableverticalGridLinesVisiblePropertyverticalZeroLineVisibleProperty

Field Detail

categoriesListenerback to summary
private ListChangeListener<String> categoriesListener
categoryAxisback to summary
private CategoryAxis categoryAxis
categoryGapback to summary
private DoubleProperty categoryGap

The gap to leave between bars in separate categories

HORIZONTAL_PSEUDOCLASS_STATEback to summary
private static final PseudoClass HORIZONTAL_PSEUDOCLASS_STATE

Pseudoclass indicating this is a horizontal chart.

orientationback to summary
private final Orientation orientation
parallelTransitionback to summary
private ParallelTransition parallelTransition
seriesCategoryMapback to summary
private Map<XYChart.Series<X, Y>, Map<String, List<XYChart.Data<X, Y>>>> seriesCategoryMap
valueAxisback to summary
private ValueAxis<T extends Number> valueAxis
VERTICAL_PSEUDOCLASS_STATEback to summary
private static final PseudoClass VERTICAL_PSEUDOCLASS_STATE

Pseudoclass indicating this is a vertical chart.

Constructor Detail

StackedBarChartback to summary
public StackedBarChart(Axis<X> xAxis, Axis<Y> yAxis)

Construct a new StackedBarChart with the given axis. The two axis should be a ValueAxis/NumberAxis and a CategoryAxis, they can be in either order depending on if you want a horizontal or vertical bar chart.

Parameters
xAxis:Axis<X>

The x axis to use

yAxis:Axis<Y>

The y axis to use

StackedBarChartback to summary
public StackedBarChart(Axis<X> xAxis, Axis<Y> yAxis, ObservableList<XYChart.Series<X, Y>> data)

Construct a new StackedBarChart with the given axis and data. The two axis should be a ValueAxis/NumberAxis and a CategoryAxis, they can be in either order depending on if you want a horizontal or vertical bar chart.

Parameters
xAxis:Axis<X>

The x axis to use

yAxis:Axis<Y>

The y axis to use

data:ObservableList<XYChart.Series<X, Y>>

The data to use, this is the actual list used so any changes to it will be reflected in the chart

StackedBarChartback to summary
public StackedBarChart(Axis<X> xAxis, Axis<Y> yAxis, ObservableList<XYChart.Series<X, Y>> data, double categoryGap)

Construct a new StackedBarChart with the given axis and data. The two axis should be a ValueAxis/NumberAxis and a CategoryAxis, they can be in either order depending on if you want a horizontal or vertical bar chart.

Parameters
xAxis:Axis<X>

The x axis to use

yAxis:Axis<Y>

The y axis to use

data:ObservableList<XYChart.Series<X, Y>>

The data to use, this is the actual list used so any changes to it will be reflected in the chart

categoryGap:double

The gap to leave between bars in separate categories

Method Detail

animateDataAddback to summary
private void animateDataAdd(XYChart.Data<X, Y> item, Node bar)
categoryGapPropertyback to summary
public DoubleProperty categoryGapProperty()
createBarback to summary
private Node createBar(XYChart.Series<X, Y> series, int seriesIndex, final XYChart.Data<X, Y> item, int itemIndex)
createDataRemoveTimelineback to summary
private Timeline createDataRemoveTimeline(XYChart.Data<X, Y> item, final Node bar, final XYChart.Series<X, Y> series)
createLegendItemForSeriesback to summary
pack-priv Legend.LegendItem createLegendItemForSeries(XYChart.Series<X, Y> series, int seriesIndex)

Overrides javafx.scene.chart.XYChart.createLegendItemForSeries.

Doc from javafx.scene.chart.XYChart.createLegendItemForSeries.

Called by the updateLegend for each series in the chart in order to create new legend item

Annotations
@Override
dataItemAddedback to summary
protected void dataItemAdded(XYChart.Series<X, Y> series, int itemIndex, XYChart.Data<X, Y> item)

Implements abstract javafx.scene.chart.XYChart.dataItemAdded.

Doc from javafx.scene.chart.XYChart.dataItemAdded.

Called when a data item has been added to a series. This is where implementations of XYChart can create/add new nodes to getPlotChildren to represent this data item. They also may animate that data add with a fade in or similar if animated = true.

Annotations
@Override
dataItemChangedback to summary
protected void dataItemChanged(XYChart.Data<X, Y> item)

Implements abstract javafx.scene.chart.XYChart.dataItemChanged.

Doc from javafx.scene.chart.XYChart.dataItemChanged.

Called when a data item has changed, ie its xValue, yValue or extraValue has changed.

Annotations
@Override
dataItemRemovedback to summary
protected void dataItemRemoved(final XYChart.Data<X, Y> item, final XYChart.Series<X, Y> series)

Implements abstract javafx.scene.chart.XYChart.dataItemRemoved.

Doc from javafx.scene.chart.XYChart.dataItemRemoved.

Called when a data item has been removed from data model but it is still visible on the chart. Its still visible so that you can handle animation for removing it in this method. After you are done animating the data item you must call removeDataItemFromDisplay() to remove the items node from being displayed on the chart.

Annotations
@Override
getCategoryGapback to summary
public double getCategoryGap()
getClassCssMetaDataback to summary
public static List<CssMetaData<? extends Styleable, ?>> getClassCssMetaData()

Hides javafx.scene.chart.XYChart.getClassCssMetaData.

Gets the CssMetaData associated with this class, which may include the CssMetaData of its superclasses.

Returns:List<CssMetaData<? extends Styleable, ?>>

the CssMetaData

Since
JavaFX 8.0
getCssMetaDataback to summary
public List<CssMetaData<? extends Styleable, ?>> getCssMetaData()

Overrides javafx.scene.chart.XYChart.getCssMetaData.

Implements javafx.css.Styleable.getCssMetaData.

Doc from javafx.scene.chart.XYChart.getCssMetaData.

This method should delegate to Node#getClassCssMetaData() so that a Node's CssMetaData can be accessed without the need for reflection.

Annotations
@Override
Since
JavaFX 8.0
getDataItemback to summary
private List<XYChart.Data<X, Y>> getDataItem(XYChart.Series<X, Y> series, String category)
layoutPlotChildrenback to summary
protected void layoutPlotChildren()

Implements abstract javafx.scene.chart.XYChart.layoutPlotChildren.

Doc from javafx.scene.chart.XYChart.layoutPlotChildren.

Called to update and layout the plot children. This should include all work to updates nodes representing the plot on top of the axis and grid lines etc. The origin is the top left of the plot area, the plot area with can be got by getting the width of the x axis and its height from the height of the y axis.

Annotations
@Override
processDataRemoveback to summary
private void processDataRemove(final XYChart.Series<X, Y> series, final XYChart.Data<X, Y> item)
seriesAddedback to summary
protected void seriesAdded(XYChart.Series<X, Y> series, int seriesIndex)

Implements abstract javafx.scene.chart.XYChart.seriesAdded.

Doc from javafx.scene.chart.XYChart.seriesAdded.

A series has been added to the charts data model. This is where implementations of XYChart can create/add new nodes to getPlotChildren to represent this series. Also you have to handle adding any data items that are already in the series. You may simply call dataItemAdded() for each one or provide some different animation for a whole series being added.

Annotations
@Override
seriesBeingRemovedIsAddedback to summary
pack-priv void seriesBeingRemovedIsAdded(XYChart.Series<X, Y> series)

Overrides javafx.scene.chart.XYChart.seriesBeingRemovedIsAdded.

Doc from javafx.scene.chart.XYChart.seriesBeingRemovedIsAdded.

This method is called when there is an attempt to add series that was set to be removed, and the removal might not have completed.

Annotations
@Override
seriesChangedback to summary
protected void seriesChanged(ListChangeListener.Change<? extends XYChart.Series<X, Y>> c)

Overrides javafx.scene.chart.XYChart.seriesChanged.

Doc from javafx.scene.chart.XYChart.seriesChanged.

Called when each atomic change is made to the list of series for this chart

Annotations
@Override
seriesRemovedback to summary
protected void seriesRemoved(final XYChart.Series<X, Y> series)

Implements abstract javafx.scene.chart.XYChart.seriesRemoved.

Doc from javafx.scene.chart.XYChart.seriesRemoved.

A series has been removed from the data model but it is still visible on the chart. Its still visible so that you can handle animation for removing it in this method. After you are done animating the data item you must call removeSeriesFromDisplay() to remove the series from the display list.

Annotations
@Override
setCategoryGapback to summary
public void setCategoryGap(double value)
updateAxisRangeback to summary
protected void updateAxisRange()

Overrides javafx.scene.chart.XYChart.updateAxisRange.

Doc from javafx.scene.chart.XYChart.updateAxisRange.

This is called when the range has been invalidated and we need to update it. If the axis are auto ranging then we compile a list of all data that the given axis has to plot and call invalidateRange() on the axis passing it that data.

Annotations
@Override
updateMapback to summary
private void updateMap(XYChart.Series<X, Y> series, XYChart.Data<X, Y> item)
javafx.scene.chart back to summary

private Class StackedBarChart.StyleableProperties

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final CssMetaData<StackedBarChart<?, ?>, Number>
private static final List<CssMetaData<? extends Styleable, ?>>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CATEGORY_GAPback to summary
private static final CssMetaData<StackedBarChart<?, ?>, Number> CATEGORY_GAP
STYLEABLESback to summary
private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES

Constructor Detail

StyleablePropertiesback to summary
private StyleableProperties()