public interface IsChart
Modifier and Type | Method and Description |
---|---|
HandlerRegistration |
addHandler(EventHandler handler,
EventType type)
Adds this handler to the widget.
|
static <T extends IsChart> |
checkAndGetIfConsistent(T chart)
Check if chart passed as argument is not
null and its id is not null as well, and if mandatory methods of interface will return consistent
instances.If not, throw a IllegalArgumentException or returns the chart instance. |
static IsChart |
checkAndGetIfValid(IsChart chart)
Check if chart passed as argument is not
null and its id is not null as well.If not, throw a IllegalArgumentException or returns the chart instance. |
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, a IllegalArgumentException 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, a IllegalArgumentException will be thrown. |
static void |
checkIfConsistent(IsChart chart)
Check if chart passed as argument is not
null and its id is not null as well, and if mandatory methods of interface will return consistent
instances.If not, throw a IllegalArgumentException . |
static void |
checkIfValid(IsChart chart)
Checks if chart passed as argument is not
null and its id is not null as well.If not, throw a IllegalArgumentException . |
void |
clear()
Will clear the chart canvas.
|
void |
createAndSetTimer(ChartTimerTask task,
int interval)
Creates a
CTimer 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 chart
|
void |
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 of
ChartType is the same of getType() otherwise, in case the type of the chart is a
ControllerType is the chart type extension if there is or null . |
Canvas |
getCanvas()
Returns the canvas element used to draw the chart.
|
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(BaseNativeEvent event)
Looks for the dataset that matches the event.
|
DatasetItem |
getDatasetItem(int index)
Looks for the dataset that matches the current index and returns.
|
IsDefaultScaledOptions |
getDefaultChartOptions()
Returns the default options created based on chart type.
|
DatasetReference |
getElementAtEvent(BaseNativeEvent 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<DatasetReference> |
getElementsAtEvent(BaseNativeEvent 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. |
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.
|
ConfigurationOptions |
getOptions()
Returns the options of chart.
|
Plugins |
getPlugins()
Returns the plugins element to manage inline plugins.
|
CTimer |
getTimer()
Returns a
CTimer 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 visible
|
IsDefaultScaledOptions |
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 to
true and updates the chart. |
static boolean |
isAbstractChart(IsChart chart)
Returns
true if chart passed as argument is an abstract chart instance. |
boolean |
isChartAttached()
Returns
true whether this chart is currently attached to the browser's document. |
static boolean |
isConsistent(IsChart chart)
Returns
true if chart passed as argument is not null and its id is not null as well, and if mandatory methods of interface will return
consistent instances. |
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()
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 |
isEventHandled(EventType type)
Returns
true if there is any event handler for event type passed as argument. |
boolean |
isInitialized()
Returns
true if CHART.JS chart has been initialized, otherwise false . |
static boolean |
isValid(IsChart chart)
Returns
true if chart passed as argument is not null and its id is not null as well. |
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(ActiveDatasetElement... elements)
Sets the active (hovered) elements for the chart.
|
void |
setActiveElements(List<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)
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 |
setTooltipActiveElements(ActiveDatasetElement... elements)
Sets the active tooltip elements for the chart.
|
void |
setTooltipActiveElements(List<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 to
false and updates the chart. |
void |
stop()
Use this to stop any current animation loop.
|
default String |
toBase64Image()
Returns a data-URL containing a representation of the image in the PNG format and the image quality value is 0.92.
|
default String |
toBase64Image(double encoderOptions)
Returns a data-URL containing a representation of the image in the PNG format.
The returned image is in a resolution of 96dpi. |
default String |
toBase64Image(ImageMimeType type)
Returns a data-URL containing a representation of the image format, passed as argument.
The returned image is in a resolution of 96dpi and the image quality value is 0.92. |
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. |
static boolean isConsistent(IsChart chart)
true
if chart passed as argument is not null
and its id is not null
as well, and if mandatory methods of interface will return
consistent instances.chart
- chart to be checkedtrue
if chart passed as argument is not null
and its id is not null
as well, and if mandatory methods of interface will return
consistent instances.static void checkIfConsistent(IsChart chart)
null
and its id is not null
as well, and if mandatory methods of interface will return consistent
instances.IllegalArgumentException
.chart
- chart to be checkedstatic <T extends IsChart> T checkAndGetIfConsistent(T chart)
null
and its id is not null
as well, and if mandatory methods of interface will return consistent
instances.IllegalArgumentException
or returns the chart instance.T
- type of the chart instancechart
- chart to be checkedstatic boolean isValid(IsChart chart)
true
if chart passed as argument is not null
and its id is not null
as well.chart
- chart to be checkedtrue
if chart passed as argument is not null
and its id is not null
as wellstatic void checkIfValid(IsChart chart)
null
and its id is not null
as well.IllegalArgumentException
.chart
- chart to be checkedstatic IsChart checkAndGetIfValid(IsChart chart)
null
and its id is not null
as well.IllegalArgumentException
or returns the chart instance.chart
- chart to be checkedstatic boolean isAbstractChart(IsChart chart)
true
if chart passed as argument is an abstract chart instance.chart
- chart to be checkedtrue
if chart passed as argument is an abstract chart instanceHandlerRegistration addHandler(EventHandler handler, EventType type)
type
- the event typehandler
- the handlervoid fireEvent(Event event)
event
- the event to fireint getHandlerCount(EventType type)
type
- event type to use to get the amount of handlersboolean isEventHandled(EventType type)
true
if there is any event handler for event type passed as argument.type
- event type to checktrue
if there is any event handler for event type passed as argumentDiv getChartElement()
boolean isChartAttached()
true
whether this chart is currently attached to the browser's document.true
whether this chart is currently attached to the browser's documentConfigurationOptions getOptions()
Type getType()
Type getBaseType()
ChartType
is the same of getType()
otherwise, in case the type of the chart is a
ControllerType
is the chart type extension if there is or null
.String getId()
Canvas getCanvas()
void removeCanvasPreventDefault()
CursorType getInitialCursor()
boolean isInitialized()
true
if CHART.JS chart has been initialized, otherwise false
.true
if CHART.JS chart has been initialized, otherwise false
.ChartNode getNode()
Data getData()
Plugins getPlugins()
IsDefaultScaledOptions getDefaultChartOptions()
IsDefaultScaledOptions getWholeOptions()
CTimer getTimer()
CTimer
instance inside chart.void createAndSetTimer(ChartTimerTask task, int interval)
CTimer
instance inside chart.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.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
.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 setboolean 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
.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 setvoid setActiveElements(List<ActiveDatasetElement> elements)
elements
- list of active elementsvoid setActiveElements(ActiveDatasetElement... elements)
elements
- array of active elementsvoid resetActiveElements()
List<ActiveDatasetElement> getActiveElements()
void setTooltipActiveElements(List<ActiveDatasetElement> elements)
elements
- list of active tooltip elementsvoid resetTooltipActiveElements()
void setTooltipActiveElements(ActiveDatasetElement... elements)
elements
- array of active tooltip elementsList<ActiveDatasetElement> getTooltipActiveElements()
void destroy()
void stop()
.render()
to re-animate.void clear()
void reset()
default String toBase64Image()
default String toBase64Image(double encoderOptions)
encoderOptions
- between 0 and 1 indicating the image quality to use for image formats that use lossy compression.default String toBase64Image(ImageMimeType type)
type
- indicating the image formatString toBase64Image(ImageMimeType type, double encoderOptions)
type
- indicating the image formatencoderOptions
- between 0 and 1 indicating the image quality to use for image formats that use lossy compression.Undefined.STRING
if chart is not initialized.void resize()
void resize(int width, int height)
width
- width size of resizeheight
- height size of resizevoid update()
void update(TransitionKey mode)
mode
- an animation mode can be provided to indicate what should be updated and what animation configuration should be usedvoid update(UpdateConfiguration config)
config
- a config object can be provided with additional configuration for the update processvoid reconfigure()
void reconfigure(TransitionKey mode)
mode
- an animation mode can be provided to indicate what should be updated and what animation configuration should be usedvoid reconfigure(UpdateConfiguration config)
config
- a configuration object can be provided with additional configuration for the update processvoid render()
.update()
in that case.DatasetItem getDatasetItem(int index)
index
- dataset indexList<DatasetReference> getDatasetAtEvent(BaseNativeEvent event)
event
- event of chart.boolean isDatasetVisible(int index)
index
- dataset indextrue
if dataset is visible otherwise false
.int getVisibleDatasetCount()
Undefined.INTEGER
.void setDatasetVisibility(int datasetIndex, boolean visibility)
datasetIndex
- dataset indexvisibility
- if true
enables the visibility otherwise false
void toggleDataVisibility(int index)
index
- data indexboolean isDataVisible(int index)
index
- data indextrue
if the data item is visiblevoid hide(int datasetIndex)
datasetIndex
- dataset indexvoid hide(int datasetIndex, int dataIndex)
true
and updates the chart.datasetIndex
- dataset indexdataIndex
- data indexvoid show(int datasetIndex)
datasetIndex
- dataset indexvoid show(int datasetIndex, int dataIndex)
false
and updates the chart.datasetIndex
- dataset indexdataIndex
- data indexDatasetReference getElementAtEvent(BaseNativeEvent event)
event
- event of chart.List<DatasetReference> getElementsAtEvent(BaseNativeEvent event)
event
- event of chart.void draw()
void checkDatasets(Dataset... datasets)
IllegalArgumentException
will be thrown.datasets
- list of datasets to check.void checkAxes(Axis... axes)
IllegalArgumentException
will be thrown.axes
- list of axes to check.