Top Description Inners Fields Constructors Methods
javafx.scene.chart

public abstract Class XYChart<X, Y>

extends Chart
Class Inheritance
Known Direct Subclasses
javafx.scene.chart.AreaChart, javafx.scene.chart.BarChart, javafx.scene.chart.BubbleChart, javafx.scene.chart.LineChart, javafx.scene.chart.ScatterChart, javafx.scene.chart.StackedAreaChart, javafx.scene.chart.StackedBarChart
Type Parameters
<X>
the X axis value type
<Y>
the Y axis value type
Imports
com.sun.javafx.charts.Legend, java.text.MessageFormat, java.util.ArrayList, .BitSet, .Collections, .HashMap, .HashSet, .Iterator, .List, .Map, .Set, com.sun.javafx.scene.control.skin.resources.ControlResources, javafx.animation.Interpolator, .KeyFrame, .KeyValue, javafx.beans.binding.StringBinding, javafx.beans.property.BooleanProperty, .ObjectProperty, .ObjectPropertyBase, .ReadOnlyObjectProperty, .ReadOnlyObjectPropertyBase, .ReadOnlyObjectWrapper, .SimpleObjectProperty, .StringProperty, .StringPropertyBase, javafx.beans.value.ObservableValue, javafx.collections.FXCollections, .ListChangeListener, .ListChangeListener.Change, .ObservableList, javafx.css.CssMetaData, .Styleable, .StyleableBooleanProperty, .StyleableProperty, javafx.geometry.Orientation, .Side, javafx.scene.Group, .Node, javafx.scene.layout.Region, javafx.scene.shape.ClosePath, .Line, .LineTo, .MoveTo, .Path, .Rectangle, javafx.util.Duration, com.sun.javafx.collections.NonIterableChange, javafx.css.converter.BooleanConverter

Chart base class for all 2 axis charts. It is responsible for drawing the two axes and the plot content. It contains a list of all content in the plot and implementations of XYChart can add nodes to this list that need to be rendered.

It is possible to install Tooltips on data items / symbols. For example the following code snippet installs Tooltip on the 1st data item.


 XYChart.Data item = ( XYChart.Data)series.getData().get(0);
 Tooltip.install(item.getNode(), new Tooltip("Symbol-0"));
Since
JavaFX 2.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
XYChart.Data<
the data X value type
X
,
the data Y value type
Y
>

A single data item with data for 2 axis charts

public static class
XYChart.Series<
the series X value type
X
,
the series Y value type
Y
>

A named series of data items

private static class

Field Summary

Modifier and TypeField and Description
private BooleanProperty
alternativeColumnFillVisible

If true then alternative vertical columns will have fills

private BooleanProperty
alternativeRowFillVisible

If true then alternative horizontal rows will have fills

private final BitSet
private ObjectProperty<ObservableList<XYChart.Series<X, Y>>>
data

XYCharts data

pack-priv static String
private final List<XYChart.Series<X, Y>>
private final Path
private BooleanProperty
horizontalGridLinesVisible

True if horizontal grid lines should be drawn

private final Path
private final Line
private BooleanProperty
horizontalZeroLineVisible

If this is true and the horizontal axis has both positive and negative values then a additional axis line will be drawn at the zero point

private Legend
private final Group
private final Rectangle
private final Region
private final Group
private boolean
private final ListChangeListener<XYChart.Series<X, Y>>
seriesChanged

This is called when a series is added or removed from the chart

pack-priv final Map<XYChart.Series<X, Y>, Integer>
private final Path
private BooleanProperty
verticalGridLinesVisible

True if vertical grid lines should be drawn

private final Path
private final Line
private BooleanProperty
verticalZeroLineVisible

If this is true and the vertical axis has both positive and negative values then a additional axis line will be drawn at the zero point

private final Axis<X>
private ReadOnlyObjectProperty<Axis<X>>
private final Axis<Y>
private ReadOnlyObjectProperty<Axis<Y>>
Inherited from javafx.scene.chart.Chart:
useChartContentMirroring

Constructor Summary

AccessConstructor and Description
public
XYChart(Axis<X>
X Axis for this XY chart
xAxis
,
Axis<Y>
Y Axis for this XY chart
yAxis
)

Constructs a XYChart given the two axes.

Method Summary

Modifier and TypeMethod and Description
public final BooleanProperty
public final BooleanProperty
pack-priv Legend.LegendItem

Returns:

new legend item for this series
createLegendItemForSeries
(XYChart.Series<X, Y>
the series for this legend item
series
,
int
the index of the series
seriesIndex
)

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

pack-priv final KeyFrame[]

Returns:

array of two KeyFrames from zero to fadeOutTime
createSeriesRemoveTimeLine
(XYChart.Series<X, Y>
The series to remove
series
,
long
Time to fade out, in milliseconds
fadeOutTime
)

Creates an array of KeyFrames for fading out nodes representing a series

protected final ObjectProperty<Object>

Returns:

ObjectProperty<Object> The current extra value ObjectProperty
currentDisplayedExtraValueProperty
(XYChart.Data<X, Y>
The XYChart.Data item from which the current extra value property object is obtained.
item
)

The current displayed extra value property.

protected final ObjectProperty<X>

Returns:

The current displayed X data value ObjectProperty.
currentDisplayedXValueProperty
(XYChart.Data<X, Y>
The XYChart.Data item from which the current X axis data value property object is obtained.
item
)

The current displayed data value property that is plotted on X axis.

protected final ObjectProperty<Y>

Returns:

The current displayed Y data value ObjectProperty.
currentDisplayedYValueProperty
(XYChart.Data<X, Y>
The XYChart.Data item from which the current Y axis data value property object is obtained.
item
)

The current displayed data value property that is plotted on Y axis.

pack-priv void
dataBeingRemovedIsAdded(XYChart.Data<X, Y> item, XYChart.Series<X, Y> series)

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

protected abstract void
dataItemAdded(XYChart.Series<X, Y>
The series the data item was added to
series
,
int
The index of the new item within the series
itemIndex
,
XYChart.Data<X, Y>
The new data item that was added
item
)

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

protected abstract void
dataItemChanged(XYChart.Data<X, Y>
The data item who was changed
item
)

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

protected abstract void
dataItemRemoved(XYChart.Data<X, Y>
The item that has been removed from the series
item
,
XYChart.Series<X, Y>
The series the item was removed from
series
)

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

private void
dataItemsChanged(XYChart.Series<X, Y> series, List<XYChart.Data<X, Y>> removed, int addedFrom, int addedTo, boolean permutation)

public final ObjectProperty<ObservableList<XYChart.Series<X, Y>>>
private <T> void
dataValueChanged(XYChart.Data<X, Y> item, T newValue, ObjectProperty<T> currentValueProperty)

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

Returns:

the CssMetaData
getClassCssMetaData
()

Hides javafx.scene.chart.Chart.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.Chart.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.

protected final Object

Returns:

The current extra value
getCurrentDisplayedExtraValue
(XYChart.Data<X, Y>
The XYChart.Data item from which the current extra value is obtained
item
)

The current displayed data extra value.

protected final X

Returns:

The current displayed X data value
getCurrentDisplayedXValue
(XYChart.Data<X, Y>
The XYChart.Data item from which the current X axis data value is obtained
item
)

The current displayed data value plotted on the X axis.

protected final Y

Returns:

The current displayed Y data value
getCurrentDisplayedYValue
(XYChart.Data<X, Y>
The XYChart.Data item from which the current Y axis data value is obtained
item
)

The current displayed data value plotted on the Y axis.

public final ObservableList<XYChart.Series<X, Y>>
pack-priv final int

Returns:

The number of items in data, or null if data is null
getDataSize
()

Gets the size of the data returning 0 if the data is null

protected final Iterator<XYChart.Data<X, Y>>

Returns:

iterator over currently displayed items from this series
getDisplayedDataIterator
(final XYChart.Series<X, Y>
The series to get displayed data for
series
)

XYChart maintains a list of all items currently displayed this includes all current data + any data items recently deleted that are in the process of being faded out.

protected final Iterator<XYChart.Series<X, Y>>

Returns:

iterator over currently displayed series
getDisplayedSeriesIterator
()

XYChart maintains a list of all series currently displayed this includes all current series + any series that have recently been deleted that are in the process of being faded (animated) out.

protected ObservableList<Node>

Returns:

Observable list of plot children
getPlotChildren
()

Modifiable and observable list of all content in the plot.

pack-priv int

Returns:

index of the series in series list
getSeriesIndex
(XYChart.Series<X, Y>
The series to find index for
series
)

Get the index of the series in the series linked list.

pack-priv int

Returns:

size of series linked list
getSeriesSize
()

Computes the size of series linked list

public final boolean

Returns:

true if verticalGridLines are visible else false.
getVerticalGridLinesVisible
()

Indicates whether vertical grid lines are visible or not.

public Axis<X>

Returns:

the X axis of the chart
getXAxis
()

Get the X axis, by default it is along the bottom of the plot

public Axis<Y>

Returns:

the Y axis of this chart
getYAxis
()

Get the Y axis, by default it is along the left of the plot

public final BooleanProperty
public final BooleanProperty
private void
invalidateRange()

This is called when a data change has happened that may cause the range to be invalid.

public final boolean
public final boolean
public final boolean
public final boolean
public final boolean
protected final void
layoutChartChildren(double top, double left, double width, double height)

Implements abstract javafx.scene.chart.Chart.layoutChartChildren.

Called to update and layout the chart children available from getChartChildren()

protected abstract void
layoutPlotChildren()

Called to update and layout the plot children.

protected final void
removeDataItemFromDisplay(XYChart.Series<X, Y>
The series to remove
series
,
XYChart.Data<X, Y>
The item to remove from series's display list
item
)

This should be called from dataItemRemoved() when you are finished with any animation for deleting the item from the chart.

protected final void
removeSeriesFromDisplay(XYChart.Series<X, Y>
The series to remove
series
)

This should be called from seriesRemoved() when you are finished with any animation for deleting the series from the chart.

protected abstract void
seriesAdded(XYChart.Series<X, Y>
The series that has been added
series
,
int
The index of the new series
seriesIndex
)

A series has been added to the charts data model.

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

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>>
a Change instance representing the changes to the series
c
)

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

private void
seriesNameChanged()

Called when a series's name has changed

protected abstract void
seriesRemoved(XYChart.Series<X, Y>
The series that has been removed
series
)

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

public final void
public final void
protected final void
setCurrentDisplayedExtraValue(XYChart.Data<X, Y>
The XYChart.Data item from which the current extra value is obtained.
item
,
Object
The extra value
value
)

Set the current displayed data extra value.

protected final void
setCurrentDisplayedXValue(XYChart.Data<X, Y>
The XYChart.Data item from which the current X axis data value is obtained.
item
,
X
The X axis data value
value
)

Set the current displayed data value plotted on X axis.

protected final void
setCurrentDisplayedYValue(XYChart.Data<X, Y>
The XYChart.Data item from which the current Y axis data value is obtained.
item
,
Y
The Y axis data value
value
)

Set the current displayed data value plotted on Y axis.

public final void
public final void
public final void
public final void
public final void
protected void
updateAxisRange()

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

protected void
updateLegend()

This is called whenever a series is added or removed and the legend needs to be updated

pack-priv void
updateSymbolFocusable(boolean on)

Overrides javafx.scene.chart.Chart.updateSymbolFocusable.

Invoked in the FX application thread when accessibility active platform property changes.

public final BooleanProperty
public final BooleanProperty
private ObservableValue<Axis<X>>
private ObservableValue<Axis<Y>>
Inherited from javafx.scene.chart.Chart:
animateanimateanimatedPropertycomputeMinHeightcomputeMinWidthcomputePrefHeightcomputePrefWidthgetAnimatedgetChartChildrengetLegendgetLegendSidegetTitlegetTitleSideisAccessibilityActiveisLegendVisiblelayoutChildrenlegendPropertylegendSidePropertylegendVisiblePropertyrequestChartLayoutsetAnimatedsetLegendsetLegendSidesetLegendVisiblesetTitlesetTitleSideshouldAnimatetitlePropertytitleSideProperty