public class DataSeries extends AbstractSeries
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.
ListSeries
,
RangeSeries
,
HeatSeries
,
Serialized FormConstructor and Description |
---|
DataSeries()
Constructs an empty
DataSeries . |
DataSeries(DataSeriesItem... items)
Constructs a new DataSeries with the given items.
|
DataSeries(List<DataSeriesItem> items)
Constructs a new DataSeries instance 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.
|
Modifier and Type | Method and Description |
---|---|
void |
add(DataSeriesItem item)
Adds a data item and immediately updates the chart if it already has been
drawn.
|
void |
add(DataSeriesItem item,
boolean updateChartImmediately,
boolean shift)
Adds a data item and immediately sends an update to the chart if so
specified.
|
void |
addData(Number[][] entries)
Adds a list of (x,y) data pairs
e.g.
|
void |
addItemWithDrilldown(DataSeriesItem item)
Adds a new item to the series data and enables drilldown for it.
|
void |
addItemWithDrilldown(DataSeriesItem item,
Series series)
Adds a new item to the series data.
|
void |
clear()
Removes all items from the series.
|
DataSeriesItem |
get(int index)
Returns
DataSeriesItem at given index |
DataSeriesItem |
get(String name) |
List<DataSeriesItem> |
getData()
Return an unmodifiable list of the data items in this series.
|
void |
remove(DataSeriesItem item)
Removes a given item and immediately removes it from the chart.
|
void |
setData(List<DataSeriesItem> data)
Sets the data to the provided list of data items.
|
void |
setData(Number... values)
Sets the data entries, first clearing the old ones.
|
void |
setData(String[] categoryNames,
Number[] values)
Sets the data entries, first clearing the old ones.
|
void |
setData(String[] categoryNames,
Number[] values,
Number[] colorIndexes)
Sets the data entries, first clearing the old ones.
|
void |
setItemSliced(int index,
boolean sliced)
Sets a new sliced value to the item with the specified index
|
void |
setItemSliced(int index,
boolean sliced,
boolean redraw)
Sets a new sliced value to the item with the specified index
|
void |
setItemSliced(int index,
boolean sliced,
boolean redraw,
boolean animation)
Sets a new sliced value to the item with the specified index
|
int |
size() |
void |
update(DataSeriesItem item)
Triggers an update of the chart for the specified data item.
|
getConfiguration, getId, getName, getPlotOptions, getStack, getxAxis, getyAxis, isVisible, setConfiguration, setId, setName, setPlotOptions, setStack, setVisible, setVisible, setxAxis, setyAxis, setyAxis, updateSeries
public DataSeries()
DataSeries
. Developers should then populate
the series with various addData and setData methods.public DataSeries(String[] categories, Number[] ys)
categories
- ys
- public DataSeries(String name)
public DataSeries(List<DataSeriesItem> items)
items
- items to be contained in the constructed DataSeriespublic DataSeries(DataSeriesItem... items)
items
- items to be contained in the constructed DataSeriespublic void addData(Number[][] entries)
[[0, 15], [10, -50], [20, -56.5]...
could be inserted as follows
new Number[][] { { 0, 15 }, { 10, -50 }, { 20, -56.5 }
entries
- An array of Numbers representing the (x,y) data pairs.public void setData(String[] categoryNames, Number[] values)
categoryNames
- An array of the category names.values
- An array of the values for each category in the categoryNames
parameter.public void setData(String[] categoryNames, Number[] values, Number[] colorIndexes)
categoryNames
- An array of the category names.values
- An array of the values for each category in the categoryNames
parameter.colorIndexes
- An array of color indexes for each category name, value pair.public void setData(Number... values)
values
- public void setData(List<DataSeriesItem> data)
data
- public DataSeriesItem get(String name)
name
- The name of the data item to find.DataSeriesItem
identified by the specified
name. Returns null if no matching item is found.public void add(DataSeriesItem item)
item
- the data item to be addedadd(DataSeriesItem, boolean, boolean)
public void addItemWithDrilldown(DataSeriesItem item, Series series)
Configuration.getDrilldown()
item
- series
- public void addItemWithDrilldown(DataSeriesItem item)
Chart#setDrilldownCallback(com.vaadin.flow.component.charts.DrilldownCallbackHandler)
to return a Series
when drilldown is done.
The remaining drilldown configurations can be set in
Configuration.getDrilldown()
item
- public void add(DataSeriesItem item, boolean updateChartImmediately, boolean shift)
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.
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.public void remove(DataSeriesItem item)
item
- The item to remove.public List<DataSeriesItem> getData()
public void update(DataSeriesItem item)
item
- The item to update.public DataSeriesItem get(int index)
DataSeriesItem
at given indexindex
- IndexOutOfBoundsException
- if data series don't have item at given indexpublic int size()
public void clear()
public void setItemSliced(int index, boolean sliced)
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 toggledpublic void setItemSliced(int index, boolean sliced, boolean redraw)
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.public void setItemSliced(int index, boolean sliced, boolean redraw, boolean animation)
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
optionsCopyright © 2025. All rights reserved.