Class Chart
- 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.dashbuilder.renderer.chartjs.lib.Chart
-
- All Implemented Interfaces:
com.google.gwt.event.dom.client.HasClickHandlers,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>,HasAnimationCompleteHandlers,HasDataSelectionEventHandlers,HasAnimation,IsResponsive
- Direct Known Subclasses:
ChartWithAnimation,ChartWithTooltip
public abstract class Chart extends com.google.gwt.user.client.ui.SimplePanel implements HasAnimationCompleteHandlers, com.google.gwt.event.dom.client.HasClickHandlers, HasAnimation, HasDataSelectionEventHandlers, IsResponsive
Base class for all chart widgets
Class describes generic behavior of all chart widgets
-
-
Field Summary
Fields Modifier and Type Field Description protected List<AnimationCallback>callbackListprotected com.google.gwt.core.client.JavaScriptObjectnativeCanvasprotected LegendOptionoptionsprotected ChartStylestyle-
Fields inherited from interface org.dashbuilder.renderer.chartjs.lib.options.HasAnimation
ANIMATION, ANIMATION_EASING, ANIMATION_STEPS
-
Fields inherited from interface org.dashbuilder.renderer.chartjs.lib.options.IsResponsive
MAINTAIN_ASPECT_RATIO, RESPONSIVE
-
-
Constructor Summary
Constructors Constructor Description Chart()Constructor creates chart with default styleChart(ChartStyle style)This constructor creates new chart instance with customChartStyle
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddAnimationCallback(AnimationCallback callback)Add animation callback to handle animation state changesvoidaddAnimationCompleteHandler(AnimationCompleteHandler handler)AddAnimationCompleteEventhandler to widget.com.google.gwt.event.shared.HandlerRegistrationaddClickHandler(com.google.gwt.event.dom.client.ClickHandler clickHandler)com.google.gwt.event.shared.HandlerRegistrationaddDataSelectionHandler(DataSelectionHandler handler)AddAnimationCompleteEventhandler to widget.protected com.google.gwt.core.client.JavaScriptObjectconstructOptions()Method returns custom options for chartprotected abstract voiddraw()Method preparing data and invoking native draw method
This method should not be overridden by sub-classesprotected com.google.gwt.core.client.JavaScriptObjectgetNativeCanvas()protected com.google.gwt.dom.client.CanvasElementgetNativeElement()com.google.gwt.user.client.ui.ImagegetSnapshot()Creates snapshot of current state of chart as imageprotected voidonAnimationComplete()protected voidonAnimationProgress(double progress)protected voidonAttach()protected voidprocessEvents(com.google.gwt.core.client.JavaScriptObject object)protected voidregisterNativeAnimationHandlers()abstract voidreload()Method requesting data from data provider and re-drawing chart.voidsetAnimationEnabled(boolean enabled)Specify should chart be animated or not Default value istruevoidsetAnimationSteps(int steps)Particularly specify quality of animation Default value is 60voidsetAnimationType(Type type)Specify animation easing Default value isType.EASE_OUT_QUARTvoidsetChartStyle(ChartStyle style)Set new style to the char widget.voidsetHeight(String height)voidsetLegendTemplate(String template)voidsetMaintainAspectRatio(boolean aspectRatio)protected voidsetNativeCanvas(com.google.gwt.core.client.JavaScriptObject object)voidsetPixelHeight(int height)Method sets pixel height of chart areavoidsetPixelWidth(int width)Method sets pixel width of chart areavoidsetResponsive(boolean responsive)voidsetWidth(String width)abstract voidupdate()Method re-drawing chart widget without re-requesting data from data provider.
To update data callreload()method instead-
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, 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, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, sinkBitlessEvent, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
options
protected LegendOption options
-
nativeCanvas
protected com.google.gwt.core.client.JavaScriptObject nativeCanvas
-
style
protected ChartStyle style
-
callbackList
protected List<AnimationCallback> callbackList
-
-
Constructor Detail
-
Chart
public Chart(ChartStyle style)
This constructor creates new chart instance with customChartStyle- Parameters:
style- - new CssResource used for styling charts
-
Chart
public Chart()
Constructor creates chart with default style
-
-
Method Detail
-
setChartStyle
public void setChartStyle(ChartStyle style)
Set new style to the char widget. New style will be injected automatically.
NOTICE: new style will be applied after re-drawing of chart- Parameters:
style-
-
processEvents
protected void processEvents(com.google.gwt.core.client.JavaScriptObject object)
-
onAttach
protected void onAttach()
- Overrides:
onAttachin classcom.google.gwt.user.client.ui.Widget
-
update
public abstract void update()
Method re-drawing chart widget without re-requesting data from data provider.
To update data callreload()method instead
-
reload
public abstract void reload()
Method requesting data from data provider and re-drawing chart.
-
draw
protected abstract void draw()
Method preparing data and invoking native draw method
This method should not be overridden by sub-classes
-
setPixelWidth
public void setPixelWidth(int width)
Method sets pixel width of chart area- Parameters:
width- - width in pixels TODO: replace it with genericsetWidth(String)andUIObject.setSize(String, String)
-
setWidth
public void setWidth(String width)
- Overrides:
setWidthin classcom.google.gwt.user.client.ui.UIObject
-
setHeight
public void setHeight(String height)
- Overrides:
setHeightin classcom.google.gwt.user.client.ui.UIObject
-
setPixelHeight
public void setPixelHeight(int height)
Method sets pixel height of chart area- Parameters:
height- - height in pixels TODO: replace it with genericsetHeight(String)andUIObject.setSize(String, String)
-
addAnimationCompleteHandler
public void addAnimationCompleteHandler(AnimationCompleteHandler handler)
Description copied from interface:HasAnimationCompleteHandlersAddAnimationCompleteEventhandler to widget.- Specified by:
addAnimationCompleteHandlerin interfaceHasAnimationCompleteHandlers
-
getSnapshot
public com.google.gwt.user.client.ui.Image getSnapshot()
Creates snapshot of current state of chart as image- Returns:
- Image object or null if Chart not rendered (or in progress)
-
addClickHandler
public com.google.gwt.event.shared.HandlerRegistration addClickHandler(com.google.gwt.event.dom.client.ClickHandler clickHandler)
- Specified by:
addClickHandlerin interfacecom.google.gwt.event.dom.client.HasClickHandlers
-
addDataSelectionHandler
public com.google.gwt.event.shared.HandlerRegistration addDataSelectionHandler(DataSelectionHandler handler)
Description copied from interface:HasDataSelectionEventHandlersAddAnimationCompleteEventhandler to widget.- Specified by:
addDataSelectionHandlerin interfaceHasDataSelectionEventHandlers
-
getNativeCanvas
protected com.google.gwt.core.client.JavaScriptObject getNativeCanvas()
-
getNativeElement
protected com.google.gwt.dom.client.CanvasElement getNativeElement()
-
setNativeCanvas
protected void setNativeCanvas(com.google.gwt.core.client.JavaScriptObject object)
-
setAnimationEnabled
public void setAnimationEnabled(boolean enabled)
Specify should chart be animated or not Default value istrue- Specified by:
setAnimationEnabledin interfaceHasAnimation- Parameters:
enabled-
-
setAnimationType
public void setAnimationType(Type type)
Specify animation easing Default value isType.EASE_OUT_QUART- Specified by:
setAnimationTypein interfaceHasAnimation- Parameters:
type-
-
addAnimationCallback
public void addAnimationCallback(AnimationCallback callback)
Add animation callback to handle animation state changes- Specified by:
addAnimationCallbackin interfaceHasAnimation- Parameters:
callback-
-
setAnimationSteps
public void setAnimationSteps(int steps)
Description copied from interface:HasAnimationParticularly specify quality of animation Default value is 60- Specified by:
setAnimationStepsin interfaceHasAnimation
-
constructOptions
protected com.google.gwt.core.client.JavaScriptObject constructOptions()
Method returns custom options for chart- Returns:
-
registerNativeAnimationHandlers
protected void registerNativeAnimationHandlers()
-
onAnimationProgress
protected void onAnimationProgress(double progress)
-
onAnimationComplete
protected void onAnimationComplete()
-
setResponsive
public void setResponsive(boolean responsive)
- Specified by:
setResponsivein interfaceIsResponsive
-
setMaintainAspectRatio
public void setMaintainAspectRatio(boolean aspectRatio)
- Specified by:
setMaintainAspectRatioin interfaceIsResponsive
-
setLegendTemplate
public void setLegendTemplate(String template)
-
-