O
- Options type for the specific chartD
- Dataset type for the specific chartpublic abstract class AbstractChart<O extends ConfigurationOptions,D extends Dataset> extends SimplePanel implements IsChart<O,D>
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
HasWidgets.ForIsWidget
DEBUG_ID_PREFIX
Constructor and Description |
---|
AbstractChart()
Initializes simple panel and canvas which are used by CHART.JS.
It sets also some default behaviors (width in percentage) for resizing |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Will clear the chart canvas.
|
protected ChartOptions |
createChartOptions()
Creates the chart options based on type of chart.
It can be override when a controller is implemented. |
protected HandlerManager |
createHandlerManager() |
void |
destroy()
Use this to destroy any chart instances that are created.
|
void |
draw()
Draws the chart
|
String |
generateLegend()
Returns an HTML string of a legend for that chart.
|
Canvas |
getCanvas()
Returns the canvas element used to draw the chart.
|
Data |
getData()
Returns the data object with all passed datasets.
|
DatasetMetaItem |
getDatasetAtEvent(ChartNativeEvent event)
Looks for the dataset that matches the event and returns that metadata.
|
DatasetMetaItem |
getDatasetMeta(int index)
Looks for the dataset that matches the current index and returns that metadata.
|
ChartOptions |
getDefaultChartOptions()
Returns the default options created based on chart type.
|
DatasetItem |
getElementAtEvent(ChartNativeEvent 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. |
List<DatasetItem> |
getElementsAtEvent(ChartNativeEvent 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. |
String |
getId()
Returns the ID of chart.
It could be considered as chart unique ID. |
ChartNode |
getNode()
Returns the chart node with runtime data.
|
Plugins |
getPlugins()
Returns the plugins element to manage inline plugins.
|
int |
getVisibleDatasetCount()
Returns the amount of datasets which are visible
|
boolean |
isDatasetVisible(int index)
Looks for the dataset if it's visible or not, selected by index.
|
boolean |
isDestroyOnDetach()
Returns
true if the chart is configured to be destroyed on the attach of DIV element, otherwise
false . |
boolean |
isDrawOnAttach()
Returns
true if the chart is configured to be drawn on the attach of DIV element, otherwise
false . |
boolean |
isInitialized()
Returns
true if CHART.JS chart has been initialized, otherwise false . |
protected void |
onAttach() |
protected void |
onDetach() |
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.
|
void |
render(UpdateConfiguration config)
Triggers a redraw of all chart elements.
|
void |
reset()
Reset the chart to it's state before the initial animation.
|
void |
resize()
Use this to manually resize the canvas element.
|
void |
setDestroyOnDetach(boolean destroyOnDetach)
Sets
true if the chart is configured to be destroyed on the attach of DIV element, otherwise
false . |
void |
setDrawOnAttach(boolean drawOnAttach)
Sets
true if the chart is configured to be draw on the attach of DIV element, otherwise false . |
void |
stop()
Use this to stop any current animation loop.
|
String |
toBase64Image()
Returns a base 64 encoded string of the chart in it's current state.
|
String |
toJSON()
Returns the string JSON representation of the object.
|
void |
update()
Triggers an update of the chart.
|
void |
update(UpdateConfiguration config)
Triggers an update of the chart.
|
add, getContainerElement, getWidget, iterator, remove, setWidget, setWidget
add, adopt, doAttachChildren, doDetachChildren, orphan, remove
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, delegateEvent, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onBrowserEvent, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getOptions, getType, newDataset
forEach, spliterator
public AbstractChart()
protected final HandlerManager createHandlerManager()
createHandlerManager
in class Widget
public final String getId()
public final Canvas getCanvas()
public final void removeCanvasPreventDefault()
public boolean isInitialized()
true
if CHART.JS chart has been initialized, otherwise false
.true
if CHART.JS chart has been initialized, otherwise false
.public final ChartNode getNode()
public final Data getData()
public final Plugins getPlugins()
protected ChartOptions createChartOptions()
public final ChartOptions getDefaultChartOptions()
public final boolean isDrawOnAttach()
true
if the chart is configured to be drawn on the attach of DIV element, otherwise
false
.true
if the chart is configured to be drawn on the attach of DIV element, otherwise
false
. Default is true
.public final void setDrawOnAttach(boolean drawOnAttach)
true
if the chart is configured to be draw on the attach of DIV element, otherwise false
.drawOnAttach
- the drawOnAttach to setpublic final boolean isDestroyOnDetach()
true
if the chart is configured to be destroyed on the attach of DIV element, otherwise
false
.true
if the chart is configured to be destroyed on the attach of DIV element,
otherwise false
. Default is true
.public final void setDestroyOnDetach(boolean destroyOnDetach)
true
if the chart is configured to be destroyed on the attach of DIV element, otherwise
false
.destroyOnDetach
- the destroyOnDetach to setpublic final void destroy()
public final void stop()
.render()
to re-animate.public final void clear()
clear
in interface HasWidgets
clear
in class Panel
public final void reset()
public final String toBase64Image()
UndefinedValues.STRING
if chart is not initialized.public final String generateLegend()
UndefinedValues.STRING
if chart is not initialized.public final void resize()
public final void update()
public final void update(UpdateConfiguration config)
config
- a config object can be provided with additional configuration for the update processpublic final void render()
.update()
in
that case.public final void render(UpdateConfiguration config)
.update()
in
that case. A config object can be provided with additional configuration for the render process. This is useful when
update is manually called inside an event handler and some different animation is desired.config
- a config object can be provided with additional configuration for the render processpublic final DatasetMetaItem getDatasetMeta(int index)
index
- dataset indexpublic DatasetMetaItem getDatasetAtEvent(ChartNativeEvent event)
event
- event of chart.public boolean isDatasetVisible(int index)
index
- dataset indextrue
if dataset is visible otherwise false
.public int getVisibleDatasetCount()
UndefinedValues.INTEGER
.public final DatasetItem getElementAtEvent(ChartNativeEvent event)
event
- event of chart.public final List<DatasetItem> getElementsAtEvent(ChartNativeEvent event)
event
- event of chart.public final void draw()
public final String toJSON()