public final class Series
extends java.lang.Object
A Series
represents a single data series:
a set of related data points to be displayed in a visualization.
For example, a line chart depicting GDP in the US and in Canada over ten years
would have two series—one for the US, and one for Canada—each with ten data points;
the two series would be displayed together on a plot.
A series has a human-readable label (like "US GDP"
),
and also one or more columns.
Each column is identified by a unique column specification.
For example, a line plot might require a NumericColumn
called X_VALUES
and another NumericColumn
called Y_VALUES
.
These columns are accessible from the data()
map:
invoking mySeries.data().get(X_VALUES)
would return the column associated with the x-values.
The framework maintains an invariant that
all columns are valid according to their respective column specifications.
That is, if series.data().get(spec) == column
,
then spec.isValid(column)
must be true
.
Thus, visualization plugins may rely on this and extract the data without performing any checks.
Constructor and Description |
---|
Series(java.lang.String label,
java.util.Map<ColumnSpecification,Column> data)
Create a series with the given legend label
and the given set of data,
which associates each column specification (as required by the series in question)
with an actual column containing the relevant data.
|
Modifier and Type | Method and Description |
---|---|
java.util.Map<ColumnSpecification,Column> |
data()
Get an unmodifiable view of the data stored in this series:
each column specification is mapped to the column that stores the actual data.
|
java.lang.String |
label()
Get the legend label associated with this series.
|
public Series(java.lang.String label, java.util.Map<ColumnSpecification,Column> data)
Create a series with the given legend label and the given set of data, which associates each column specification (as required by the series in question) with an actual column containing the relevant data.
It is a requirement that each key–value pair in the map respect validity:
that is, if data.get(spec) == column
,
then it must be true that spec.isValid(column)
.
label
- the label associated with this series
(as might be displayed in a legend)data
- the map from each column specification to the actual column datajava.lang.NullPointerException
- if label == null
, or data == null
,
or data
contains any null
keys or valuespublic java.lang.String label()
public java.util.Map<ColumnSpecification,Column> data()