Class AbstractChartWidget<C extends IsChart>
- java.lang.Object
-
- com.google.gwt.user.client.ui.UIObject
-
- com.google.gwt.user.client.ui.Widget
-
- com.google.gwt.user.client.ui.Panel
-
- com.google.gwt.user.client.ui.SimplePanel
-
- org.pepstock.charba.client.gwt.widgets.AbstractChartWidget<C>
-
- Type Parameters:
C
- type for the specific chart
- All Implemented Interfaces:
com.google.gwt.event.logical.shared.HasAttachHandlers
,com.google.gwt.event.shared.HasHandlers
,com.google.gwt.user.client.EventListener
,com.google.gwt.user.client.ui.AcceptsOneWidget
,com.google.gwt.user.client.ui.HasOneWidget
,com.google.gwt.user.client.ui.HasVisibility
,com.google.gwt.user.client.ui.HasWidgets
,com.google.gwt.user.client.ui.HasWidgets.ForIsWidget
,com.google.gwt.user.client.ui.IsWidget
,Iterable<com.google.gwt.user.client.ui.Widget>
,IsChart
- Direct Known Subclasses:
AreaChartWidget
,BarChartWidget
,BubbleChartWidget
,BubbleMapChartWidget
,ChoroplethChartWidget
,DoughnutChartWidget
,GaugeChartWidget
,HorizontalBarChartWidget
,LineChartWidget
,MatrixChartWidget
,MeterChartWidget
,PieChartWidget
,PolarAreaChartWidget
,RadarChartWidget
,SankeyChartWidget
,ScatterChartWidget
,StackedAreaChartWidget
,StackedBarChartWidget
,StackedHorizontalBarChartWidget
,StackedLineChartWidget
,StackedVerticalLineChartWidget
,TimeSeriesBarChartWidget
,TimeSeriesLineChartWidget
,TreeMapChartWidget
,VerticalLineChartWidget
public abstract class AbstractChartWidget<C extends IsChart> extends com.google.gwt.user.client.ui.SimplePanel implements IsChart
Base class of all GWT WIDGET charts.- Author:
- Andrea "Stock" Stocchero
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractChartWidget(C chart)
Creates a chart widget for GWT by chart element instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HandlerRegistration
addHandler(EventHandler handler, EventType type)
Adds this handler to the widget.void
checkAxes(Axis... axes)
Checks if axes, requested to be stored, are an acceptable type or amount.
If a axis type or the amount of axes are not consistent for the chart, aIllegalArgumentException
will be thrown.void
checkDatasets(Dataset... datasets)
Checks if datasets, requested to be stored, are an acceptable type or amount.
If a dataset type or the amount of datasets are not consistent for the chart, aIllegalArgumentException
will be thrown.void
createAndSetTimer(ChartTimerTask task, int interval)
Creates aCTimer
instance inside chart.
It can be created only once during the life cycle of the chart.void
destroy()
Use this to destroy any chart instances that are created.void
draw()
Draws the chartvoid
fireEvent(Event event)
Fires the event to the handlers.List<ActiveDatasetElement>
getActiveElements()
Returns the active (hovered) elements for the chart.Type
getBaseType()
Returns the base type of chart that in case ofChartType
is the same ofIsChart.getType()
otherwise, in case the type of the chart is aControllerType
is the chart type extension if there is ornull
.Canvas
getCanvas()
Returns the canvas element used to draw the chart.C
getChart()
Returns the chart instance, wrapped by this GWT widget.Div
getChartElement()
Gets a handle to the object's underlying DOM element.Data
getData()
Returns the data object with all passed datasets.List<DatasetReference>
getDatasetAtEvent(NativeBaseEvent event)
Looks for the dataset that matches the event.DatasetItem
getDatasetItem(int index)
Looks for the dataset that matches the current index and returns.NativeObjectContainerFactory<DatasetReference>
getDatasetReferenceFactory()
Returns the factory to createDatasetReference
when required, based on the data element type of the chart.IsDefaultScaledOptions
getDefaultChartOptions()
Returns the default options created based on chart type.int
getDrawCount()
Returns the draw count of the chart.DatasetReference
getElementAtEvent(NativeBaseEvent event)
Calling on your chart instance passing an argument of an event, will return the single element at the event position.
If there are multiple items within range, only the first is returned.DatasetReference
getElementAtEvent(NativeBaseEvent event, InteractionOptions interaction)
Calling on your chart instance passing an argument of an event, will return the single element at the event position.
If there are multiple items within range, only the first is returned.List<DatasetReference>
getElementsAtEvent(NativeBaseEvent event)
Looks for the element under the event point, then returns all elements at the same data index.
Calling it on your chart instance passing an argument of an event, will return the point elements that are at that the same position of that event.List<DatasetReference>
getElementsAtEvent(NativeBaseEvent event, InteractionOptions interaction)
Looks for the element under the event point, then returns all elements at the same data index.
Calling it on your chart instance passing an argument of an event, will return the point elements that are at that the same position of that event.int
getHandlerCount(EventType type)
Returns the amount of handlers for a specific event type.String
getId()
Returns the ID of chart.
It could be considered as chart unique ID.CursorType
getInitialCursor()
Returns the initial cursor of the chart.ChartNode
getNode()
Returns the chart node with runtime data.Plugins
getPlugins()
Returns the plugins element to manage inline plugins.List<DatasetItem>
getSortedVisibleDatasetItems()
Returns an array of all the dataset items in the order that they are drawn on the canvas that are not hidden.CTimer
getTimer()
Returns aCTimer
instance inside chart.List<ActiveDatasetElement>
getTooltipActiveElements()
Returns the active tooltip elements for the chart.Type
getType()
Returns the type of chart.int
getVisibleDatasetCount()
Returns the amount of datasets which are visibleIsDefaultScaledOptions
getWholeOptions()
Returns the default options by a chart instance, merging global, chart type global and chart options.void
hide(int datasetIndex)
Sets the visibility for the given dataset to false.
Updates the chart and animates the dataset with 'hide' mode.
This animation can be configured under the hide key in animation options.void
hide(int datasetIndex, int dataIndex)
Sets the hidden flag of that element index totrue
and updates the chart.boolean
isChartAttached()
Returnstrue
whether this chart is currently attached to the browser's document.boolean
isDatasetVisible(int index)
Looks for the dataset if it's visible or not, selected by index.boolean
isDataVisible(int index)
Returns the stored visibility state of an data index for all datasets.boolean
isDestroyOnDetach()
Returnstrue
if the chart is configured to be destroyed on the attach of DIV element, otherwisefalse
.boolean
isDrawOnAttach()
Returnstrue
if the chart is configured to be drawn on the attach of DIV element, otherwisefalse
.boolean
isEventHandled(EventType type)
Returnstrue
if there is any event handler for event type passed as argument.boolean
isInitialized()
Returnstrue
if CHART.JS chart has been initialized, otherwisefalse
.boolean
isPluginEnabled(String pluginId)
Check if a plugin with the specific ID is registered and enabled.void
reconfigure()
Triggers an update of the chart.
This can be safely called after updating the data object.
This will update the options, mutating the options property in place.void
reconfigure(TransitionKey mode)
Triggers an update of the chart.
This can be safely called after updating the data object.
This will update the options, mutating the options property in place.
A animation mode key can be provided for the update process using a specific animation configuration.
This is useful when update is manually called inside an event handler and some different animation is desired.void
reconfigure(UpdateConfiguration config)
Triggers an update of the chart.
This can be safely called after updating the data object.
This will update the options, mutating the options property in place.
A configuration object can be provided with additional configuration for the update process.
This is useful when update is manually called inside an event handler and some different animation is desired.void
removeCanvasPreventDefault()
Remove the registration of prevent default mouse listener from canvas.
This is necessary when you will add your mouse down listener.void
render()
Triggers a redraw of all chart elements.
Note, this does not update elements for new data.void
reset()
Reset the chart to it's state before the initial animation.void
resetActiveElements()
Resets the active (hovered) elements for the chart.void
resetTooltipActiveElements()
Resets the active tooltip elements for the chart.void
resize()
Use this to manually resize the canvas element.void
resize(int width, int height)
Use this to manually resize the canvas element.
This is run each time the canvas container is resized, but can be called this method manually if you change the size of the canvas nodes container element.void
setActiveElements(List<ActiveDatasetElement> elements)
Sets the active (hovered) elements for the chart.void
setActiveElements(ActiveDatasetElement... elements)
Sets the active (hovered) elements for the chart.void
setDatasetVisibility(int datasetIndex, boolean visibility)
Sets the visibility for a given dataset.
This can be used to build a chart legend in HTML.
During click on one of the HTML items, you can call it to change the appropriate dataset.void
setDestroyOnDetach(boolean destroyOnDetach)
Setstrue
if the chart is configured to be destroyed on the attach of DIV element, otherwisefalse
.void
setDrawOnAttach(boolean drawOnAttach)
Setstrue
if the chart is configured to be draw on the attach of DIV element, otherwisefalse
.void
setTooltipActiveElements(List<ActiveDatasetElement> elements)
Sets the active tooltip elements for the chart.void
setTooltipActiveElements(IsPoint point, List<ActiveDatasetElement> elements)
Sets the active tooltip elements for the chart.void
setTooltipActiveElements(IsPoint point, ActiveDatasetElement... elements)
Sets the active tooltip elements for the chart.void
setTooltipActiveElements(ActiveDatasetElement... elements)
Sets the active tooltip elements for the chart.void
show(int datasetIndex)
Sets the visibility for the given dataset to true.
Updates the chart and animates the dataset with 'show' mode.
This animation can be configured under the show key in animation options.void
show(int datasetIndex, int dataIndex)
Sets the hidden flag of that element index tofalse
and updates the chart.void
stop()
Use this to stop any current animation loop.String
toBase64Image(ImageMimeType type, double encoderOptions)
Returns a base 64 encoded string of the chart in it's current state.void
toggleDataVisibility(int index)
Toggles the visibility of an item in all datasets.
A dataset needs to explicitly support this feature for it to have an effect.
From internal chart types, doughnut / pie and polar area use this.void
update()
Triggers an update of the chart.
This can be safely called after updating the data object.
This will update all scales, legends, and then re-render the chart.void
update(TransitionKey mode)
Triggers an update of the chart.
This can be safely called after updating the data object.
This will update all scales, legends, and then re-render the chart.
A config object can be provided with additional configuration for the update process.
This is useful when update is manually called inside an event handler and some different animation is desired.void
update(UpdateConfiguration config)
Triggers an update of the chart.
This can be safely called after updating the data object.
This will update all scales, legends, and then re-render the chart.
A config object can be provided with additional configuration for the update process.
This is useful when update is manually called inside an event handler and some different animation is desired.-
Methods inherited from class com.google.gwt.user.client.ui.SimplePanel
add, getContainerElement, getWidget, iterator, remove, setWidget, setWidget
-
Methods inherited from class com.google.gwt.user.client.ui.Panel
add, adopt, clear, doAttachChildren, doDetachChildren, orphan, remove
-
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onBrowserEvent, onDetach, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
-
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.pepstock.charba.client.IsChart
clear, getOptions, toBase64Image, toBase64Image, toBase64Image
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
AbstractChartWidget
protected AbstractChartWidget(C chart)
Creates a chart widget for GWT by chart element instance.- Parameters:
chart
- chart instance to wrap by the widget
-
-
Method Detail
-
getChart
public final C getChart()
Returns the chart instance, wrapped by this GWT widget.- Returns:
- the chart instance, wrapped by this GWT widget
-
fireEvent
public final void fireEvent(Event event)
Description copied from interface:IsChart
Fires the event to the handlers.
-
addHandler
public final HandlerRegistration addHandler(EventHandler handler, EventType type)
Description copied from interface:IsChart
Adds this handler to the widget.- Specified by:
addHandler
in interfaceIsChart
- Parameters:
handler
- the handlertype
- the event type- Returns:
- handler registration used to remove the handler
-
getHandlerCount
public int getHandlerCount(EventType type)
Description copied from interface:IsChart
Returns the amount of handlers for a specific event type.- Specified by:
getHandlerCount
in interfaceIsChart
- Parameters:
type
- event type to use to get the amount of handlers- Returns:
- the amount of handlers for a specific event type
-
isEventHandled
public boolean isEventHandled(EventType type)
Description copied from interface:IsChart
Returnstrue
if there is any event handler for event type passed as argument.- Specified by:
isEventHandled
in interfaceIsChart
- Parameters:
type
- event type to check- Returns:
true
if there is any event handler for event type passed as argument
-
getChartElement
public final Div getChartElement()
Description copied from interface:IsChart
Gets a handle to the object's underlying DOM element.- Specified by:
getChartElement
in interfaceIsChart
- Returns:
- the object's browser element
-
isChartAttached
public final boolean isChartAttached()
Description copied from interface:IsChart
Returnstrue
whether this chart is currently attached to the browser's document.- Specified by:
isChartAttached
in interfaceIsChart
- Returns:
true
whether this chart is currently attached to the browser's document
-
getType
public final Type getType()
Description copied from interface:IsChart
Returns the type of chart.
-
getBaseType
public final Type getBaseType()
Description copied from interface:IsChart
Returns the base type of chart that in case ofChartType
is the same ofIsChart.getType()
otherwise, in case the type of the chart is aControllerType
is the chart type extension if there is ornull
.- Specified by:
getBaseType
in interfaceIsChart
- Returns:
- the base type of chart.
-
getId
public final String getId()
Description copied from interface:IsChart
Returns the ID of chart.
It could be considered as chart unique ID.
-
getDrawCount
public int getDrawCount()
Description copied from interface:IsChart
Returns the draw count of the chart.- Specified by:
getDrawCount
in interfaceIsChart
- Returns:
- the draw count of the chart
-
getCanvas
public final Canvas getCanvas()
Description copied from interface:IsChart
Returns the canvas element used to draw the chart.
-
removeCanvasPreventDefault
public final void removeCanvasPreventDefault()
Description copied from interface:IsChart
Remove the registration of prevent default mouse listener from canvas.
This is necessary when you will add your mouse down listener.- Specified by:
removeCanvasPreventDefault
in interfaceIsChart
-
getInitialCursor
public final CursorType getInitialCursor()
Description copied from interface:IsChart
Returns the initial cursor of the chart.- Specified by:
getInitialCursor
in interfaceIsChart
- Returns:
- the initial cursor of the chart.
-
isInitialized
public final boolean isInitialized()
Description copied from interface:IsChart
Returnstrue
if CHART.JS chart has been initialized, otherwisefalse
.- Specified by:
isInitialized
in interfaceIsChart
- Returns:
true
if CHART.JS chart has been initialized, otherwisefalse
.
-
getNode
public final ChartNode getNode()
Description copied from interface:IsChart
Returns the chart node with runtime data.
-
getData
public final Data getData()
Description copied from interface:IsChart
Returns the data object with all passed datasets.
-
getPlugins
public final Plugins getPlugins()
Description copied from interface:IsChart
Returns the plugins element to manage inline plugins.- Specified by:
getPlugins
in interfaceIsChart
- Returns:
- the plugins configuration object
-
getDefaultChartOptions
public final IsDefaultScaledOptions getDefaultChartOptions()
Description copied from interface:IsChart
Returns the default options created based on chart type.- Specified by:
getDefaultChartOptions
in interfaceIsChart
- Returns:
- the default options of the chart
-
getWholeOptions
public final IsDefaultScaledOptions getWholeOptions()
Description copied from interface:IsChart
Returns the default options by a chart instance, merging global, chart type global and chart options.- Specified by:
getWholeOptions
in interfaceIsChart
- Returns:
- the default options by a chart instance, merging global, chart type global and chart options
-
getTimer
public final CTimer getTimer()
Description copied from interface:IsChart
Returns aCTimer
instance inside chart.
-
createAndSetTimer
public final void createAndSetTimer(ChartTimerTask task, int interval)
Description copied from interface:IsChart
Creates aCTimer
instance inside chart.
It can be created only once during the life cycle of the chart.- Specified by:
createAndSetTimer
in interfaceIsChart
- Parameters:
task
- the task to be executed repeatedlyinterval
- the time, in milliseconds (thousands of a second), the timer should delay in between executions of the specified task.
Must be greater than 0.
-
isDrawOnAttach
public final boolean isDrawOnAttach()
Description copied from interface:IsChart
Returnstrue
if the chart is configured to be drawn on the attach of DIV element, otherwisefalse
.- Specified by:
isDrawOnAttach
in interfaceIsChart
- Returns:
- the drawOnAttach
true
if the chart is configured to be drawn on the attach of DIV element, otherwisefalse
.
-
setDrawOnAttach
public final void setDrawOnAttach(boolean drawOnAttach)
Description copied from interface:IsChart
Setstrue
if the chart is configured to be draw on the attach of DIV element, otherwisefalse
.- Specified by:
setDrawOnAttach
in interfaceIsChart
- Parameters:
drawOnAttach
- the drawOnAttach to set
-
isDestroyOnDetach
public final boolean isDestroyOnDetach()
Description copied from interface:IsChart
Returnstrue
if the chart is configured to be destroyed on the attach of DIV element, otherwisefalse
.- Specified by:
isDestroyOnDetach
in interfaceIsChart
- Returns:
- the destroyOnDetach
true
if the chart is configured to be destroyed on the attach of DIV element, otherwisefalse
.
-
setDestroyOnDetach
public final void setDestroyOnDetach(boolean destroyOnDetach)
Description copied from interface:IsChart
Setstrue
if the chart is configured to be destroyed on the attach of DIV element, otherwisefalse
.- Specified by:
setDestroyOnDetach
in interfaceIsChart
- Parameters:
destroyOnDetach
- the destroyOnDetach to set
-
setActiveElements
public void setActiveElements(List<ActiveDatasetElement> elements)
Description copied from interface:IsChart
Sets the active (hovered) elements for the chart.- Specified by:
setActiveElements
in interfaceIsChart
- Parameters:
elements
- list of active elements
-
setActiveElements
public void setActiveElements(ActiveDatasetElement... elements)
Description copied from interface:IsChart
Sets the active (hovered) elements for the chart.- Specified by:
setActiveElements
in interfaceIsChart
- Parameters:
elements
- array of active elements
-
resetActiveElements
public void resetActiveElements()
Description copied from interface:IsChart
Resets the active (hovered) elements for the chart.- Specified by:
resetActiveElements
in interfaceIsChart
-
getActiveElements
public List<ActiveDatasetElement> getActiveElements()
Description copied from interface:IsChart
Returns the active (hovered) elements for the chart.- Specified by:
getActiveElements
in interfaceIsChart
- Returns:
- the list of active elements
-
setTooltipActiveElements
public void setTooltipActiveElements(List<ActiveDatasetElement> elements)
Description copied from interface:IsChart
Sets the active tooltip elements for the chart.- Specified by:
setTooltipActiveElements
in interfaceIsChart
- Parameters:
elements
- list of active tooltip elements
-
setTooltipActiveElements
public void setTooltipActiveElements(ActiveDatasetElement... elements)
Description copied from interface:IsChart
Sets the active tooltip elements for the chart.- Specified by:
setTooltipActiveElements
in interfaceIsChart
- Parameters:
elements
- array of active tooltip elements
-
setTooltipActiveElements
public void setTooltipActiveElements(IsPoint point, List<ActiveDatasetElement> elements)
Description copied from interface:IsChart
Sets the active tooltip elements for the chart.- Specified by:
setTooltipActiveElements
in interfaceIsChart
- Parameters:
point
- synthetic event position used in positioningelements
- list of active tooltip elements
-
setTooltipActiveElements
public void setTooltipActiveElements(IsPoint point, ActiveDatasetElement... elements)
Description copied from interface:IsChart
Sets the active tooltip elements for the chart.- Specified by:
setTooltipActiveElements
in interfaceIsChart
- Parameters:
point
- synthetic event position used in positioningelements
- array of active tooltip elements
-
resetTooltipActiveElements
public void resetTooltipActiveElements()
Description copied from interface:IsChart
Resets the active tooltip elements for the chart.- Specified by:
resetTooltipActiveElements
in interfaceIsChart
-
getTooltipActiveElements
public List<ActiveDatasetElement> getTooltipActiveElements()
Description copied from interface:IsChart
Returns the active tooltip elements for the chart.- Specified by:
getTooltipActiveElements
in interfaceIsChart
- Returns:
- the array of active tooltip elements
-
destroy
public final void destroy()
Description copied from interface:IsChart
Use this to destroy any chart instances that are created. This will clean up any references stored to the chart object within Chart.js, along with any associated event listeners attached by Chart.js.
-
stop
public final void stop()
Description copied from interface:IsChart
Use this to stop any current animation loop. This will pause the chart during any current animation frame. Call.render()
to re-animate.
-
reset
public final void reset()
Description copied from interface:IsChart
Reset the chart to it's state before the initial animation. A new animation can then be triggered using update.
-
toBase64Image
public String toBase64Image(ImageMimeType type, double encoderOptions)
Description copied from interface:IsChart
Returns a base 64 encoded string of the chart in it's current state.- Specified by:
toBase64Image
in interfaceIsChart
- Parameters:
type
- indicating the image formatencoderOptions
- between 0 and 1 indicating the image quality to use for image formats that use lossy compression.
If this argument is anything else, the default value for image quality is used. The default value is 0.92.- Returns:
- base 64 image or
Undefined.STRING
if chart is not initialized.
-
resize
public final void resize()
Description copied from interface:IsChart
Use this to manually resize the canvas element. This is run each time the canvas container is resized, but can be called this method manually if you change the size of the canvas nodes container element.
-
resize
public void resize(int width, int height)
Description copied from interface:IsChart
Use this to manually resize the canvas element.
This is run each time the canvas container is resized, but can be called this method manually if you change the size of the canvas nodes container element.
-
update
public final void update()
Description copied from interface:IsChart
Triggers an update of the chart.
This can be safely called after updating the data object.
This will update all scales, legends, and then re-render the chart.
-
update
public final void update(TransitionKey mode)
Description copied from interface:IsChart
Triggers an update of the chart.
This can be safely called after updating the data object.
This will update all scales, legends, and then re-render the chart.
A config object can be provided with additional configuration for the update process.
This is useful when update is manually called inside an event handler and some different animation is desired.
-
update
public final void update(UpdateConfiguration config)
Description copied from interface:IsChart
Triggers an update of the chart.
This can be safely called after updating the data object.
This will update all scales, legends, and then re-render the chart.
A config object can be provided with additional configuration for the update process.
This is useful when update is manually called inside an event handler and some different animation is desired.
-
reconfigure
public void reconfigure()
Description copied from interface:IsChart
Triggers an update of the chart.
This can be safely called after updating the data object.
This will update the options, mutating the options property in place.- Specified by:
reconfigure
in interfaceIsChart
-
reconfigure
public void reconfigure(TransitionKey mode)
Description copied from interface:IsChart
Triggers an update of the chart.
This can be safely called after updating the data object.
This will update the options, mutating the options property in place.
A animation mode key can be provided for the update process using a specific animation configuration.
This is useful when update is manually called inside an event handler and some different animation is desired.- Specified by:
reconfigure
in interfaceIsChart
- Parameters:
mode
- an animation mode can be provided to indicate what should be updated and what animation configuration should be used
-
reconfigure
public void reconfigure(UpdateConfiguration config)
Description copied from interface:IsChart
Triggers an update of the chart.
This can be safely called after updating the data object.
This will update the options, mutating the options property in place.
A configuration object can be provided with additional configuration for the update process.
This is useful when update is manually called inside an event handler and some different animation is desired.- Specified by:
reconfigure
in interfaceIsChart
- Parameters:
config
- a configuration object can be provided with additional configuration for the update process
-
render
public final void render()
Description copied from interface:IsChart
Triggers a redraw of all chart elements.
Note, this does not update elements for new data. Use.update()
in that case.
-
getDatasetItem
public final DatasetItem getDatasetItem(int index)
Description copied from interface:IsChart
Looks for the dataset that matches the current index and returns.- Specified by:
getDatasetItem
in interfaceIsChart
- Parameters:
index
- dataset index- Returns:
- dataset item.
-
getSortedVisibleDatasetItems
public final List<DatasetItem> getSortedVisibleDatasetItems()
Description copied from interface:IsChart
Returns an array of all the dataset items in the order that they are drawn on the canvas that are not hidden.- Specified by:
getSortedVisibleDatasetItems
in interfaceIsChart
- Returns:
- an array of all the dataset items in the order that they are drawn on the canvas that are not hidden.
-
getDatasetAtEvent
public final List<DatasetReference> getDatasetAtEvent(NativeBaseEvent event)
Description copied from interface:IsChart
Looks for the dataset that matches the event.- Specified by:
getDatasetAtEvent
in interfaceIsChart
- Parameters:
event
- event of chart.- Returns:
- dataset item.
-
isDatasetVisible
public final boolean isDatasetVisible(int index)
Description copied from interface:IsChart
Looks for the dataset if it's visible or not, selected by index.- Specified by:
isDatasetVisible
in interfaceIsChart
- Parameters:
index
- dataset index- Returns:
true
if dataset is visible otherwisefalse
.
-
getVisibleDatasetCount
public final int getVisibleDatasetCount()
Description copied from interface:IsChart
Returns the amount of datasets which are visible- Specified by:
getVisibleDatasetCount
in interfaceIsChart
- Returns:
- the amount of datasets which are visible. If chart is not initialized, return
Undefined.INTEGER
.
-
setDatasetVisibility
public void setDatasetVisibility(int datasetIndex, boolean visibility)
Description copied from interface:IsChart
Sets the visibility for a given dataset.
This can be used to build a chart legend in HTML.
During click on one of the HTML items, you can call it to change the appropriate dataset.- Specified by:
setDatasetVisibility
in interfaceIsChart
- Parameters:
datasetIndex
- dataset indexvisibility
- iftrue
enables the visibility otherwisefalse
-
toggleDataVisibility
public void toggleDataVisibility(int index)
Description copied from interface:IsChart
Toggles the visibility of an item in all datasets.
A dataset needs to explicitly support this feature for it to have an effect.
From internal chart types, doughnut / pie and polar area use this.- Specified by:
toggleDataVisibility
in interfaceIsChart
- Parameters:
index
- data index
-
isDataVisible
public boolean isDataVisible(int index)
Description copied from interface:IsChart
Returns the stored visibility state of an data index for all datasets.- Specified by:
isDataVisible
in interfaceIsChart
- Parameters:
index
- data index- Returns:
true
if the data item is visible
-
hide
public void hide(int datasetIndex)
Description copied from interface:IsChart
Sets the visibility for the given dataset to false.
Updates the chart and animates the dataset with 'hide' mode.
This animation can be configured under the hide key in animation options.
-
hide
public void hide(int datasetIndex, int dataIndex)
Description copied from interface:IsChart
Sets the hidden flag of that element index totrue
and updates the chart.
-
show
public void show(int datasetIndex)
Description copied from interface:IsChart
Sets the visibility for the given dataset to true.
Updates the chart and animates the dataset with 'show' mode.
This animation can be configured under the show key in animation options.
-
show
public void show(int datasetIndex, int dataIndex)
Description copied from interface:IsChart
Sets the hidden flag of that element index tofalse
and updates the chart.
-
getElementAtEvent
public final DatasetReference getElementAtEvent(NativeBaseEvent event)
Description copied from interface:IsChart
Calling on your chart instance passing an argument of an event, will return the single element at the event position.
If there are multiple items within range, only the first is returned.- Specified by:
getElementAtEvent
in interfaceIsChart
- Parameters:
event
- event of chart.- Returns:
- single element at the event position or null.
-
getElementAtEvent
public DatasetReference getElementAtEvent(NativeBaseEvent event, InteractionOptions interaction)
Description copied from interface:IsChart
Calling on your chart instance passing an argument of an event, will return the single element at the event position.
If there are multiple items within range, only the first is returned.- Specified by:
getElementAtEvent
in interfaceIsChart
- Parameters:
event
- event of chart.interaction
- how the elements will be checked.- Returns:
- single element at the event position or
null
if event is not consistent
-
getElementsAtEvent
public final List<DatasetReference> getElementsAtEvent(NativeBaseEvent event)
Description copied from interface:IsChart
Looks for the element under the event point, then returns all elements at the same data index.
Calling it on your chart instance passing an argument of an event, will return the point elements that are at that the same position of that event.- Specified by:
getElementsAtEvent
in interfaceIsChart
- Parameters:
event
- event of chart.- Returns:
- all elements at the same data index or an empty list.
-
getElementsAtEvent
public List<DatasetReference> getElementsAtEvent(NativeBaseEvent event, InteractionOptions interaction)
Description copied from interface:IsChart
Looks for the element under the event point, then returns all elements at the same data index.
Calling it on your chart instance passing an argument of an event, will return the point elements that are at that the same position of that event.- Specified by:
getElementsAtEvent
in interfaceIsChart
- Parameters:
event
- event of chart.interaction
- how the elements will be checked.- Returns:
- all elements at the same data index or an empty list.
-
getDatasetReferenceFactory
public NativeObjectContainerFactory<DatasetReference> getDatasetReferenceFactory()
Description copied from interface:IsChart
Returns the factory to createDatasetReference
when required, based on the data element type of the chart.- Specified by:
getDatasetReferenceFactory
in interfaceIsChart
- Returns:
- the factory to create
DatasetReference
when required, based on the data element type of the chart
-
isPluginEnabled
public boolean isPluginEnabled(String pluginId)
Description copied from interface:IsChart
Check if a plugin with the specific ID is registered and enabled.- Specified by:
isPluginEnabled
in interfaceIsChart
- Parameters:
pluginId
- the ID of the plugin of which to check if it is enabled- Returns:
- boolean returns true if plugin is registered and enabled
-
draw
public final void draw()
Description copied from interface:IsChart
Draws the chart
-
checkDatasets
public final void checkDatasets(Dataset... datasets)
Description copied from interface:IsChart
Checks if datasets, requested to be stored, are an acceptable type or amount.
If a dataset type or the amount of datasets are not consistent for the chart, aIllegalArgumentException
will be thrown.- Specified by:
checkDatasets
in interfaceIsChart
- Parameters:
datasets
- list of datasets to check.
-
checkAxes
public final void checkAxes(Axis... axes)
Description copied from interface:IsChart
Checks if axes, requested to be stored, are an acceptable type or amount.
If a axis type or the amount of axes are not consistent for the chart, aIllegalArgumentException
will be thrown.
-
-