Class DataSeries
java.lang.Object
com.vaadin.flow.component.charts.model.AbstractConfigurationObject
com.vaadin.flow.component.charts.model.AbstractSeries
com.vaadin.flow.component.charts.model.DataSeries
- All Implemented Interfaces:
Series,Serializable
- Direct Known Subclasses:
RangeSeries
An array of data points to be displayed in a chart.
The class uses DataSeriesItem to represent individual data points.
The class also has various helper methods and constructors that allow passing
data as arrays or lists.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs an emptyDataSeries.DataSeries(DataSeriesItem... items) Constructs a new DataSeries with the given items.DataSeries(String name) Constructs a new DataSeries instance with the given name.DataSeries(String[] categories, Number[] ys) Constructs a DataSeries instance containing the given category name, Y value pairs.DataSeries(List<DataSeriesItem> items) Constructs a new DataSeries instance with the given items. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(DataSeriesItem item) Adds a data item and immediately updates the chart if it already has been drawn.voidadd(DataSeriesItem item, boolean updateChartImmediately, boolean shift) Adds a data item and immediately sends an update to the chart if so specified.voidAdds a list of (x,y) data pairs e.g.voidAdds a new item to the series data and enables drilldown for it.voidaddItemWithDrilldown(DataSeriesItem item, Series series) Adds a new item to the series data.voidclear()Removes all items from the series.get(int index) ReturnsDataSeriesItemat given indexgetData()Return an unmodifiable list of the data items in this series.voidremove(DataSeriesItem item) Removes a given item and immediately removes it from the chart.voidSets the data entries, first clearing the old ones.voidSets the data entries, first clearing the old ones.voidSets the data entries, first clearing the old ones.voidsetData(List<DataSeriesItem> data) Sets the data to the provided list of data items.voidsetItemSliced(int index, boolean sliced) Sets a new sliced value to the item with the specified indexvoidsetItemSliced(int index, boolean sliced, boolean redraw) Sets a new sliced value to the item with the specified indexvoidsetItemSliced(int index, boolean sliced, boolean redraw, boolean animation) Sets a new sliced value to the item with the specified indexintsize()voidupdate(DataSeriesItem item) Triggers an update of the chart for the specified data item.Methods inherited from class com.vaadin.flow.component.charts.model.AbstractSeries
getColorAxis, getConfiguration, getId, getName, getPlotOptions, getStack, getxAxis, getyAxis, isVisible, setColorAxis, setConfiguration, setId, setName, setPlotOptions, setStack, setVisible, setVisible, setxAxis, setyAxis, setyAxis, updateSeries
-
Constructor Details
-
DataSeries
public DataSeries()Constructs an emptyDataSeries. Developers should then populate the series with various addData and setData methods. -
DataSeries
Constructs a DataSeries instance containing the given category name, Y value pairs.- Parameters:
categories-ys-
-
DataSeries
Constructs a new DataSeries instance with the given name. -
DataSeries
Constructs a new DataSeries instance with the given items.- Parameters:
items- items to be contained in the constructed DataSeries
-
DataSeries
Constructs a new DataSeries with the given items.- Parameters:
items- items to be contained in the constructed DataSeries
-
-
Method Details
-
addData
Adds a list of (x,y) data pairs e.g.[[0, 15], [10, -50], [20, -56.5]...could be inserted as followsnew Number[][] { { 0, 15 }, { 10, -50 }, { 20, -56.5 }- Parameters:
entries- An array of Numbers representing the (x,y) data pairs.
-
setData
Sets the data entries, first clearing the old ones. Uses the given category names and numeric values. The categoryNames and values arrays must be of equal length.- Parameters:
categoryNames- An array of the category names.values- An array of the values for each category in the categoryNames parameter.
-
setData
Sets the data entries, first clearing the old ones. Uses the given category names, numeric values, and colors. The categoryNames, values and colors arrays must be of equal length.- Parameters:
categoryNames- An array of the category names.values- An array of the values for each category in the categoryNames parameter.colors- An array of colors for each category name, value pair.
-
setData
Sets the data entries, first clearing the old ones. Uses the same numeric value for names (value.toString) and Y-values.- Parameters:
values-
-
setData
Sets the data to the provided list of data items.- Parameters:
data-
-
get
- Parameters:
name- The name of the data item to find.- Returns:
- The first
DataSeriesItemidentified by the specified name. Returns null if no matching item is found.
-
add
Adds a data item and immediately updates the chart if it already has been drawn. If the chart has not yet been drawn, all items added will be added to the chart when the chart is drawn.- Parameters:
item- the data item to be added- See Also:
-
addItemWithDrilldown
Adds a new item to the series data. And sets the series as its drilldown. Used for eager loading drilldown. Series must have an id. The remaining drilldown configurations can be set inConfiguration.getDrilldown()- Parameters:
item-series-
-
addItemWithDrilldown
Adds a new item to the series data and enables drilldown for it. Used for lazy loading drilldown. Using async drilldown requires settingChart.setDrilldownCallback(DrilldownCallback)to return aSerieswhen drilldown is done. The remaining drilldown configurations can be set inConfiguration.getDrilldown()- Parameters:
item-
-
add
Adds a data item and immediately sends an update to the chart if so specified. Immediately updating the chart causes it to dynamically add the data point.This method is useful if you want to add many items without a client/server round-trip for each item added. Do this by setting the updateChartImmediately parameter to false.
- Parameters:
item- The item to add.updateChartImmediately- Updates the chart immediately if true.shift- If true, the first item from the series is removed. Handy if dynamically adjusting adding points and fixed amount of points should be kept visible.
-
remove
Removes a given item and immediately removes it from the chart.- Parameters:
item- The item to remove.
-
getData
Return an unmodifiable list of the data items in this series. -
update
Triggers an update of the chart for the specified data item. Only the Y value of the DataSeriesItem is updated.- Parameters:
item- The item to update.
-
get
ReturnsDataSeriesItemat given index- Parameters:
index-- Returns:
- the Item
- Throws:
IndexOutOfBoundsException- if data series don't have item at given index
-
size
public int size()- Returns:
- the number of data items in the series
-
clear
public void clear()Removes all items from the series. -
setItemSliced
public void setItemSliced(int index, boolean sliced) Sets a new sliced value to the item with the specified index- Parameters:
index- Index of the Item to modifysliced- When true, the point is sliced out. When false, the point is set in. When null the sliced state is toggled
-
setItemSliced
public void setItemSliced(int index, boolean sliced, boolean redraw) Sets a new sliced value to the item with the specified index- Parameters:
index- Index of the Item to modifysliced- When true, the point is sliced out. When false, the point is set in. When null the sliced state is toggledredraw- Whether to redraw the chart after the point is altered.
-
setItemSliced
public void setItemSliced(int index, boolean sliced, boolean redraw, boolean animation) Sets a new sliced value to the item with the specified index- Parameters:
index- Index of the Item to modifysliced- When true, the point is sliced out. When false, the point is set in. When null the sliced state is toggledredraw- Whether to redraw the chart after the point is altered.animation- When true, the move will be animated with default animation options
-