Package org.pepstock.charba.client.data
Class Data
- java.lang.Object
-
- org.pepstock.charba.client.commons.NativeObjectContainer
-
- org.pepstock.charba.client.data.Data
-
- All Implemented Interfaces:
ConfigurationElement
,HasLabels
public final class Data extends NativeObjectContainer implements ConfigurationElement, HasLabels
CHART.JS entity object to configure the data options of a chart.
It contains labels and data sets.- Author:
- Andrea "Stock" Stocchero
-
-
Constructor Summary
Constructors Constructor Description Data(ChartEnvelop<IsChart> envelop)
Creates the object with an empty native object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<ActiveDatasetElement>
createActiveElementsByDataIndex(int... dataIndexes)
Creates a list of active elements instances by an array of data indexes, for all visible data sets.List<ActiveDatasetElement>
createActiveElementsByDatasetIndex(int... datasetIndexes)
Creates a list of active elements instances by an array of data set indexes, for visible data sets.List<Dataset>
getDatasets()
Returns the list of data sets.List<Dataset>
getDatasets(boolean binding)
Returns the list of data sets.LabelsHandler
getLabelsHandler()
Returns an labels option handler instance.Labels
getXLabels()
Returns the labels for X axes.Labels
getXLabels(boolean binding)
Returns the labels for X axes.Labels
getYLabels()
Returns the labels for Y axes.Labels
getYLabels(boolean binding)
Returns the labels for Y axes.boolean
isCanvasObjectHandling()
Returnstrue
if the plugin to manage canvas object (gradients and patterns) has been forcedly disable.
Pay attention that disabling the handler, your data sets configuration with gradients or patterns will e showed with default color.void
load(IsChart chart, Configuration configuration)
Called to enable to load in the a configuration object the specific configuration item (by native object).Dataset
retrieveDataset(DatasetContext context)
Returns a data set instance by scriptable context, data set index and index.Dataset
retrieveDataset(LegendItem legendItem)
Returns a data set instance by legend item locator, data set index and index.Dataset
retrieveDataset(TooltipItem tooltipItem)
Returns a data set instance by tooltip item locator, data set index and index.Gradient
retrieveFillStyleAsGradient(LegendItem legendItem)
Returns a gradient object set as background color for a data set related to legend item.Pattern
retrieveFillStyleAsPattern(LegendItem legendItem)
Returns a pattern object set as background color for a data set related to legend item.Gradient
retrieveStrokeStyleAsGradient(LegendItem legendItem)
Returns a gradient object set as border color for a data set related to legend item.Pattern
retrieveStrokeStyleAsPattern(LegendItem legendItem)
Returns a pattern object set as border color for a data set related to legend item.void
setCanvasObjectHandling(boolean canvasObjectHandling)
Setstrue
if the plugin to manage canvas object (gradients and patterns) have to be forcedly disable.
Pay attention that disabling the handler, your data sets configuration with gradients or patterns will e showed with default color.void
setDatasets(Dataset... datasets)
Sets a set of data sets for chart.void
setXLabels(String... labels)
Sets the labels for X axes of the data.void
setXLabels(Labels labels)
Sets the labels for X axes of the data.void
setYLabels(String... labels)
Sets the labels for Y axes of the data.void
setYLabels(Labels labels)
Sets the labels for Y axes of the data.-
Methods inherited from class org.pepstock.charba.client.commons.NativeObjectContainer
checkDefaultValuesArgument, empty, getArrayValue, getElement, getIncrementalId, getNativeChart, getNativeEvent, getNativeObject, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValueForMultipleKeyTypes, getValueForMultipleKeyTypes, getValueForMultipleKeyTypes, getValueOrArray, getValueOrArray, getValueOrArray, getValueOrArray, getValueOrArray, getValueOrArray, getValueOrArray, getValueOrArray, has, has, isType, keys, loadNativeObject, remove, remove, setArrayValue, setArrayValue, setArrayValue, setElement, setEmptyValue, setNewIncrementalId, setNewIncrementalId, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, toJSON, type
-
-
-
-
Constructor Detail
-
Data
public Data(ChartEnvelop<IsChart> envelop)
Creates the object with an empty native object.- Parameters:
envelop
- envelop containing the chart instance
-
-
Method Detail
-
getLabelsHandler
public LabelsHandler getLabelsHandler()
Description copied from interface:HasLabels
Returns an labels option handler instance.- Specified by:
getLabelsHandler
in interfaceHasLabels
- Returns:
- an labels option handler instance
-
setXLabels
public void setXLabels(String... labels)
Sets the labels for X axes of the data.- Parameters:
labels
- array of labels
-
setXLabels
public void setXLabels(Labels labels)
Sets the labels for X axes of the data.- Parameters:
labels
- labels object to manage also multi-line labels
-
getXLabels
public Labels getXLabels()
Returns the labels for X axes.- Returns:
- the labels for X axes
-
getXLabels
public Labels getXLabels(boolean binding)
Returns the labels for X axes.- Parameters:
binding
- iftrue
binds the new labels in the container- Returns:
- the labels for X axes
-
setYLabels
public void setYLabels(String... labels)
Sets the labels for Y axes of the data.- Parameters:
labels
- array of labels
-
setYLabels
public void setYLabels(Labels labels)
Sets the labels for Y axes of the data.- Parameters:
labels
- labels object to manage also multiple line labels
-
getYLabels
public Labels getYLabels()
Returns the labels for Y axes.- Returns:
- the labels for Y axes
-
getYLabels
public Labels getYLabels(boolean binding)
Returns the labels for Y axes.- Parameters:
binding
- iftrue
binds the new labels in the container- Returns:
- the labels for Y axes
-
setDatasets
public void setDatasets(Dataset... datasets)
Sets a set of data sets for chart. If argument isnull
, removes all data sets.- Parameters:
datasets
- set of data set. Ifnull
, removes all data sets
-
getDatasets
public List<Dataset> getDatasets()
Returns the list of data sets.- Returns:
- the list of data sets
-
getDatasets
public List<Dataset> getDatasets(boolean binding)
Returns the list of data sets.- Parameters:
binding
- iftrue
binds the new array list in the container- Returns:
- the list of data sets
-
isCanvasObjectHandling
public boolean isCanvasObjectHandling()
Returnstrue
if the plugin to manage canvas object (gradients and patterns) has been forcedly disable.
Pay attention that disabling the handler, your data sets configuration with gradients or patterns will e showed with default color.- Returns:
true
if the plugin to manage canvas object (gradients and patterns) has been forcedly disable
-
setCanvasObjectHandling
public void setCanvasObjectHandling(boolean canvasObjectHandling)
Setstrue
if the plugin to manage canvas object (gradients and patterns) have to be forcedly disable.
Pay attention that disabling the handler, your data sets configuration with gradients or patterns will e showed with default color.- Parameters:
canvasObjectHandling
-true
if the plugin to manage canvas object (gradients and patterns) have to be forcedly disable
-
createActiveElementsByDatasetIndex
public List<ActiveDatasetElement> createActiveElementsByDatasetIndex(int... datasetIndexes)
Creates a list of active elements instances by an array of data set indexes, for visible data sets.- Parameters:
datasetIndexes
- an array of data set indexes- Returns:
- a list of active elements instances by an array of data set indexes
-
createActiveElementsByDataIndex
public List<ActiveDatasetElement> createActiveElementsByDataIndex(int... dataIndexes)
Creates a list of active elements instances by an array of data indexes, for all visible data sets.- Parameters:
dataIndexes
- an array of data indexes- Returns:
- a list of active elements instances by an array of data indexes
-
retrieveFillStyleAsGradient
public final Gradient retrieveFillStyleAsGradient(LegendItem legendItem)
Returns a gradient object set as background color for a data set related to legend item.- Parameters:
legendItem
- legend item instance to get the data set related to.- Returns:
- a gradient object or
null
if not found by legend item
-
retrieveStrokeStyleAsGradient
public final Gradient retrieveStrokeStyleAsGradient(LegendItem legendItem)
Returns a gradient object set as border color for a data set related to legend item.- Parameters:
legendItem
- legend item instance to get the data set related to.- Returns:
- a gradient object or
null
if not found by legend item
-
retrieveFillStyleAsPattern
public final Pattern retrieveFillStyleAsPattern(LegendItem legendItem)
Returns a pattern object set as background color for a data set related to legend item.- Parameters:
legendItem
- legend item instance to get the data set related to.- Returns:
- a pattern object or
null
if not found by legend item
-
retrieveStrokeStyleAsPattern
public final Pattern retrieveStrokeStyleAsPattern(LegendItem legendItem)
Returns a pattern object set as border color for a data set related to legend item.- Parameters:
legendItem
- legend item instance to get the data set related to.- Returns:
- a pattern object or
null
if not found by legend item
-
retrieveDataset
public final Dataset retrieveDataset(LegendItem legendItem)
Returns a data set instance by legend item locator, data set index and index.- Parameters:
legendItem
- legend item instance to get the data set related to.- Returns:
- a data set instance or
null
if not found by legend item
-
retrieveDataset
public final Dataset retrieveDataset(TooltipItem tooltipItem)
Returns a data set instance by tooltip item locator, data set index and index.- Parameters:
tooltipItem
- tooltip item instance to get the data set related to.- Returns:
- a data set instance or
null
if not found by tooltip item
-
retrieveDataset
public final Dataset retrieveDataset(DatasetContext context)
Returns a data set instance by scriptable context, data set index and index.- Parameters:
context
- legend item instance to get the data set related to.- Returns:
- a data set instance by scriptable context item or
null
if not found by scriptable context
-
load
public void load(IsChart chart, Configuration configuration)
Description copied from interface:ConfigurationElement
Called to enable to load in the a configuration object the specific configuration item (by native object).- Specified by:
load
in interfaceConfigurationElement
- Parameters:
chart
- chart instanceconfiguration
- chart configuration instance
-
-