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 protectedAbstractChartWidget(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 HandlerRegistrationaddHandler(EventHandler handler, EventType type)Adds this handler to the widget.voidcheckAxes(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, aIllegalArgumentExceptionwill be thrown.voidcheckDatasets(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, aIllegalArgumentExceptionwill be thrown.voidcreateAndSetTimer(ChartTimerTask task, int interval)Creates aCTimerinstance inside chart.
It can be created only once during the life cycle of the chart.voiddestroy()Use this to destroy any chart instances that are created.voiddraw()Draws the chartvoidfireEvent(Event event)Fires the event to the handlers.List<ActiveDatasetElement>getActiveElements()Returns the active (hovered) elements for the chart.TypegetBaseType()Returns the base type of chart that in case ofChartTypeis the same ofIsChart.getType()otherwise, in case the type of the chart is aControllerTypeis the chart type extension if there is ornull.CanvasgetCanvas()Returns the canvas element used to draw the chart.CgetChart()Returns the chart instance, wrapped by this GWT widget.DivgetChartElement()Gets a handle to the object's underlying DOM element.DatagetData()Returns the data object with all passed datasets.List<DatasetReference>getDatasetAtEvent(NativeBaseEvent event)Looks for the dataset that matches the event.DatasetItemgetDatasetItem(int index)Looks for the dataset that matches the current index and returns.NativeObjectContainerFactory<DatasetReference>getDatasetReferenceFactory()Returns the factory to createDatasetReferencewhen required, based on the data element type of the chart.IsDefaultScaledOptionsgetDefaultChartOptions()Returns the default options created based on chart type.intgetDrawCount()Returns the draw count of the chart.DatasetReferencegetElementAtEvent(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.DatasetReferencegetElementAtEvent(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.intgetHandlerCount(EventType type)Returns the amount of handlers for a specific event type.StringgetId()Returns the ID of chart.
It could be considered as chart unique ID.CursorTypegetInitialCursor()Returns the initial cursor of the chart.ChartNodegetNode()Returns the chart node with runtime data.PluginsgetPlugins()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.CTimergetTimer()Returns aCTimerinstance inside chart.List<ActiveDatasetElement>getTooltipActiveElements()Returns the active tooltip elements for the chart.TypegetType()Returns the type of chart.intgetVisibleDatasetCount()Returns the amount of datasets which are visibleIsDefaultScaledOptionsgetWholeOptions()Returns the default options by a chart instance, merging global, chart type global and chart options.voidhide(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.voidhide(int datasetIndex, int dataIndex)Sets the hidden flag of that element index totrueand updates the chart.booleanisChartAttached()Returnstruewhether this chart is currently attached to the browser's document.booleanisDatasetVisible(int index)Looks for the dataset if it's visible or not, selected by index.booleanisDataVisible(int index)Returns the stored visibility state of an data index for all datasets.booleanisDestroyOnDetach()Returnstrueif the chart is configured to be destroyed on the attach of DIV element, otherwisefalse.booleanisDrawOnAttach()Returnstrueif the chart is configured to be drawn on the attach of DIV element, otherwisefalse.booleanisEventHandled(EventType type)Returnstrueif there is any event handler for event type passed as argument.booleanisInitialized()Returnstrueif CHART.JS chart has been initialized, otherwisefalse.booleanisPluginEnabled(String pluginId)Check if a plugin with the specific ID is registered and enabled.voidreconfigure()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.voidreconfigure(TransitionMode 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.voidreconfigure(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.voidremoveCanvasPreventDefault()Remove the registration of prevent default mouse listener from canvas.
This is necessary when you will add your mouse down listener.voidrender()Triggers a redraw of all chart elements.
Note, this does not update elements for new data.voidreset()Reset the chart to it's state before the initial animation.voidresetActiveElements()Resets the active (hovered) elements for the chart.voidresetTooltipActiveElements()Resets the active tooltip elements for the chart.voidresize()Use this to manually resize the canvas element.voidresize(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.voidsetActiveElements(List<ActiveDatasetElement> elements)Sets the active (hovered) elements for the chart.voidsetActiveElements(ActiveDatasetElement... elements)Sets the active (hovered) elements for the chart.voidsetDatasetVisibility(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.voidsetDestroyOnDetach(boolean destroyOnDetach)Setstrueif the chart is configured to be destroyed on the attach of DIV element, otherwisefalse.voidsetDrawOnAttach(boolean drawOnAttach)Setstrueif the chart is configured to be draw on the attach of DIV element, otherwisefalse.voidsetTooltipActiveElements(List<ActiveDatasetElement> elements)Sets the active tooltip elements for the chart.voidsetTooltipActiveElements(IsPoint point, List<ActiveDatasetElement> elements)Sets the active tooltip elements for the chart.voidsetTooltipActiveElements(IsPoint point, ActiveDatasetElement... elements)Sets the active tooltip elements for the chart.voidsetTooltipActiveElements(ActiveDatasetElement... elements)Sets the active tooltip elements for the chart.voidshow(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.voidshow(int datasetIndex, int dataIndex)Sets the hidden flag of that element index tofalseand updates the chart.voidstop()Use this to stop any current animation loop.StringtoBase64Image(ImageMimeType type, double encoderOptions)Returns a base 64 encoded string of the chart in it's current state.voidtoggleDataVisibility(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.voidupdate()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.voidupdate(TransitionMode 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.voidupdate(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:IsChartFires the event to the handlers.
-
addHandler
public final HandlerRegistration addHandler(EventHandler handler, EventType type)
Description copied from interface:IsChartAdds this handler to the widget.- Specified by:
addHandlerin 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:IsChartReturns the amount of handlers for a specific event type.- Specified by:
getHandlerCountin 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:IsChartReturnstrueif there is any event handler for event type passed as argument.- Specified by:
isEventHandledin interfaceIsChart- Parameters:
type- event type to check- Returns:
trueif there is any event handler for event type passed as argument
-
getChartElement
public final Div getChartElement()
Description copied from interface:IsChartGets a handle to the object's underlying DOM element.- Specified by:
getChartElementin interfaceIsChart- Returns:
- the object's browser element
-
isChartAttached
public final boolean isChartAttached()
Description copied from interface:IsChartReturnstruewhether this chart is currently attached to the browser's document.- Specified by:
isChartAttachedin interfaceIsChart- Returns:
truewhether this chart is currently attached to the browser's document
-
getType
public final Type getType()
Description copied from interface:IsChartReturns the type of chart.
-
getBaseType
public final Type getBaseType()
Description copied from interface:IsChartReturns the base type of chart that in case ofChartTypeis the same ofIsChart.getType()otherwise, in case the type of the chart is aControllerTypeis the chart type extension if there is ornull.- Specified by:
getBaseTypein interfaceIsChart- Returns:
- the base type of chart.
-
getId
public final String getId()
Description copied from interface:IsChartReturns the ID of chart.
It could be considered as chart unique ID.
-
getDrawCount
public int getDrawCount()
Description copied from interface:IsChartReturns the draw count of the chart.- Specified by:
getDrawCountin interfaceIsChart- Returns:
- the draw count of the chart
-
getCanvas
public final Canvas getCanvas()
Description copied from interface:IsChartReturns the canvas element used to draw the chart.
-
removeCanvasPreventDefault
public final void removeCanvasPreventDefault()
Description copied from interface:IsChartRemove the registration of prevent default mouse listener from canvas.
This is necessary when you will add your mouse down listener.- Specified by:
removeCanvasPreventDefaultin interfaceIsChart
-
getInitialCursor
public final CursorType getInitialCursor()
Description copied from interface:IsChartReturns the initial cursor of the chart.- Specified by:
getInitialCursorin interfaceIsChart- Returns:
- the initial cursor of the chart.
-
isInitialized
public final boolean isInitialized()
Description copied from interface:IsChartReturnstrueif CHART.JS chart has been initialized, otherwisefalse.- Specified by:
isInitializedin interfaceIsChart- Returns:
trueif CHART.JS chart has been initialized, otherwisefalse.
-
getNode
public final ChartNode getNode()
Description copied from interface:IsChartReturns the chart node with runtime data.
-
getData
public final Data getData()
Description copied from interface:IsChartReturns the data object with all passed datasets.
-
getPlugins
public final Plugins getPlugins()
Description copied from interface:IsChartReturns the plugins element to manage inline plugins.- Specified by:
getPluginsin interfaceIsChart- Returns:
- the plugins configuration object
-
getDefaultChartOptions
public final IsDefaultScaledOptions getDefaultChartOptions()
Description copied from interface:IsChartReturns the default options created based on chart type.- Specified by:
getDefaultChartOptionsin interfaceIsChart- Returns:
- the default options of the chart
-
getWholeOptions
public final IsDefaultScaledOptions getWholeOptions()
Description copied from interface:IsChartReturns the default options by a chart instance, merging global, chart type global and chart options.- Specified by:
getWholeOptionsin 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:IsChartReturns aCTimerinstance inside chart.
-
createAndSetTimer
public final void createAndSetTimer(ChartTimerTask task, int interval)
Description copied from interface:IsChartCreates aCTimerinstance inside chart.
It can be created only once during the life cycle of the chart.- Specified by:
createAndSetTimerin 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:IsChartReturnstrueif the chart is configured to be drawn on the attach of DIV element, otherwisefalse.- Specified by:
isDrawOnAttachin interfaceIsChart- Returns:
- the drawOnAttach
trueif 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:IsChartSetstrueif the chart is configured to be draw on the attach of DIV element, otherwisefalse.- Specified by:
setDrawOnAttachin interfaceIsChart- Parameters:
drawOnAttach- the drawOnAttach to set
-
isDestroyOnDetach
public final boolean isDestroyOnDetach()
Description copied from interface:IsChartReturnstrueif the chart is configured to be destroyed on the attach of DIV element, otherwisefalse.- Specified by:
isDestroyOnDetachin interfaceIsChart- Returns:
- the destroyOnDetach
trueif 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:IsChartSetstrueif the chart is configured to be destroyed on the attach of DIV element, otherwisefalse.- Specified by:
setDestroyOnDetachin interfaceIsChart- Parameters:
destroyOnDetach- the destroyOnDetach to set
-
setActiveElements
public void setActiveElements(List<ActiveDatasetElement> elements)
Description copied from interface:IsChartSets the active (hovered) elements for the chart.- Specified by:
setActiveElementsin interfaceIsChart- Parameters:
elements- list of active elements
-
setActiveElements
public void setActiveElements(ActiveDatasetElement... elements)
Description copied from interface:IsChartSets the active (hovered) elements for the chart.- Specified by:
setActiveElementsin interfaceIsChart- Parameters:
elements- array of active elements
-
resetActiveElements
public void resetActiveElements()
Description copied from interface:IsChartResets the active (hovered) elements for the chart.- Specified by:
resetActiveElementsin interfaceIsChart
-
getActiveElements
public List<ActiveDatasetElement> getActiveElements()
Description copied from interface:IsChartReturns the active (hovered) elements for the chart.- Specified by:
getActiveElementsin interfaceIsChart- Returns:
- the list of active elements
-
setTooltipActiveElements
public void setTooltipActiveElements(List<ActiveDatasetElement> elements)
Description copied from interface:IsChartSets the active tooltip elements for the chart.- Specified by:
setTooltipActiveElementsin interfaceIsChart- Parameters:
elements- list of active tooltip elements
-
setTooltipActiveElements
public void setTooltipActiveElements(ActiveDatasetElement... elements)
Description copied from interface:IsChartSets the active tooltip elements for the chart.- Specified by:
setTooltipActiveElementsin interfaceIsChart- Parameters:
elements- array of active tooltip elements
-
setTooltipActiveElements
public void setTooltipActiveElements(IsPoint point, List<ActiveDatasetElement> elements)
Description copied from interface:IsChartSets the active tooltip elements for the chart.- Specified by:
setTooltipActiveElementsin 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:IsChartSets the active tooltip elements for the chart.- Specified by:
setTooltipActiveElementsin interfaceIsChart- Parameters:
point- synthetic event position used in positioningelements- array of active tooltip elements
-
resetTooltipActiveElements
public void resetTooltipActiveElements()
Description copied from interface:IsChartResets the active tooltip elements for the chart.- Specified by:
resetTooltipActiveElementsin interfaceIsChart
-
getTooltipActiveElements
public List<ActiveDatasetElement> getTooltipActiveElements()
Description copied from interface:IsChartReturns the active tooltip elements for the chart.- Specified by:
getTooltipActiveElementsin interfaceIsChart- Returns:
- the array of active tooltip elements
-
destroy
public final void destroy()
Description copied from interface:IsChartUse 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:IsChartUse 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:IsChartReset 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:IsChartReturns a base 64 encoded string of the chart in it's current state.- Specified by:
toBase64Imagein 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.STRINGif chart is not initialized.
-
resize
public final void resize()
Description copied from interface:IsChartUse 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:IsChartUse 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:IsChartTriggers 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(TransitionMode mode)
Description copied from interface:IsChartTriggers 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:IsChartTriggers 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:IsChartTriggers 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:
reconfigurein interfaceIsChart
-
reconfigure
public void reconfigure(TransitionMode mode)
Description copied from interface:IsChartTriggers 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:
reconfigurein 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:IsChartTriggers 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:
reconfigurein 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:IsChartTriggers 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:IsChartLooks for the dataset that matches the current index and returns.- Specified by:
getDatasetItemin interfaceIsChart- Parameters:
index- dataset index- Returns:
- dataset item.
-
getSortedVisibleDatasetItems
public final List<DatasetItem> getSortedVisibleDatasetItems()
Description copied from interface:IsChartReturns an array of all the dataset items in the order that they are drawn on the canvas that are not hidden.- Specified by:
getSortedVisibleDatasetItemsin 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:IsChartLooks for the dataset that matches the event.- Specified by:
getDatasetAtEventin interfaceIsChart- Parameters:
event- event of chart.- Returns:
- dataset item.
-
isDatasetVisible
public final boolean isDatasetVisible(int index)
Description copied from interface:IsChartLooks for the dataset if it's visible or not, selected by index.- Specified by:
isDatasetVisiblein interfaceIsChart- Parameters:
index- dataset index- Returns:
trueif dataset is visible otherwisefalse.
-
getVisibleDatasetCount
public final int getVisibleDatasetCount()
Description copied from interface:IsChartReturns the amount of datasets which are visible- Specified by:
getVisibleDatasetCountin 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:IsChartSets 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:
setDatasetVisibilityin interfaceIsChart- Parameters:
datasetIndex- dataset indexvisibility- iftrueenables the visibility otherwisefalse
-
toggleDataVisibility
public void toggleDataVisibility(int index)
Description copied from interface:IsChartToggles 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:
toggleDataVisibilityin interfaceIsChart- Parameters:
index- data index
-
isDataVisible
public boolean isDataVisible(int index)
Description copied from interface:IsChartReturns the stored visibility state of an data index for all datasets.- Specified by:
isDataVisiblein interfaceIsChart- Parameters:
index- data index- Returns:
trueif the data item is visible
-
hide
public void hide(int datasetIndex)
Description copied from interface:IsChartSets 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:IsChartSets the hidden flag of that element index totrueand updates the chart.
-
show
public void show(int datasetIndex)
Description copied from interface:IsChartSets 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:IsChartSets the hidden flag of that element index tofalseand updates the chart.
-
getElementAtEvent
public final DatasetReference getElementAtEvent(NativeBaseEvent event)
Description copied from interface:IsChartCalling 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:
getElementAtEventin 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:IsChartCalling 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:
getElementAtEventin interfaceIsChart- Parameters:
event- event of chart.interaction- how the elements will be checked.- Returns:
- single element at the event position or
nullif event is not consistent
-
getElementsAtEvent
public final List<DatasetReference> getElementsAtEvent(NativeBaseEvent event)
Description copied from interface:IsChartLooks 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:
getElementsAtEventin 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:IsChartLooks 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:
getElementsAtEventin 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:IsChartReturns the factory to createDatasetReferencewhen required, based on the data element type of the chart.- Specified by:
getDatasetReferenceFactoryin interfaceIsChart- Returns:
- the factory to create
DatasetReferencewhen required, based on the data element type of the chart
-
isPluginEnabled
public boolean isPluginEnabled(String pluginId)
Description copied from interface:IsChartCheck if a plugin with the specific ID is registered and enabled.- Specified by:
isPluginEnabledin 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:IsChartDraws the chart
-
checkDatasets
public final void checkDatasets(Dataset... datasets)
Description copied from interface:IsChartChecks 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, aIllegalArgumentExceptionwill be thrown.- Specified by:
checkDatasetsin interfaceIsChart- Parameters:
datasets- list of datasets to check.
-
checkAxes
public final void checkAxes(Axis... axes)
Description copied from interface:IsChartChecks 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, aIllegalArgumentExceptionwill be thrown.
-
-