Class Chart
- All Implemented Interfaces:
Serializable,Cloneable,org.zkoss.zk.ui.Component,org.zkoss.zk.ui.ext.Scope,org.zkoss.zk.ui.sys.ComponentCtrl
Chart requires an implementation of an engine (ChartEngine).
The default engine is based on JFreeChart and available in ZK PE and ZK EE.
The model and type must match to each other; or the result is unpredictable. The 3D chart is not supported on all chart type.
| type | model | 3D |
|---|---|---|
| area | CategoryModel or XYModel | No |
| bar | CategoryModel | Yes |
| bubble | XYZModel | No |
| candlestick | HiLoModel | No |
| dial | @{link DialModel} | No |
| gantt | GanttModel | No |
| highlow | HiLoModel | No |
| histogram | XYModel | No |
| line | CategoryModel or XYModel | Yes |
| pie | PieModel | Yes |
| polar | XYModel | No |
| ring | PieModel | No |
| scatter | XYModel | No |
| stacked_bar | CategoryModel | Yes |
| stacked_area | CategoryModel or XYModel | No |
| step | XYModel | No |
| step_area | XYModel | No |
| time_series | XYModel | No |
| wafermap | WaferMapModel | No |
| waterfall | CategoryModel | No |
| wind | XYZModel | No |
- Author:
- henrichen
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.zkoss.zul.Image
Image.ExtraCtrlNested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent
org.zkoss.zk.ui.AbstractComponent.Children, org.zkoss.zk.ui.AbstractComponent.ForwardInfo, org.zkoss.zk.ui.AbstractComponent.TargetInfo -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class org.zkoss.zk.ui.HtmlBasedComponent
_zclassFields inherited from interface org.zkoss.zk.ui.Component
APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPEFields inherited from interface org.zkoss.zk.ui.sys.ComponentCtrl
AFTER_CHILD_ADDED, AFTER_CHILD_REMOVED, AFTER_CLONED, AFTER_PAGE_ATTACHED, AFTER_PAGE_DETACHED, AFTER_PARENT_CHANGED, CE_BUSY_IGNORE, CE_DUPLICATE_IGNORE, CE_IMPORTANT, CE_NON_DEFERRABLE, CE_REPEAT_IGNORE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddEventListener(String evtnm, org.zkoss.zk.ui.event.EventListener<? extends org.zkoss.zk.ui.event.Event> listener) clone()Returns the renderer to render each area, or null if the default renderer is used.intGet the background alpha (transparency, 0 ~ 255, opaque).Get the background color of the chart (in string as #RRGGBB).int[]getBgRGB()Get the background color in int array (0: red, 1: green, 2:blue).Returns the date format used by date related Chart.Returns the implementation chart engine.intGet the foreground alpha (transparency, 0 ~ 255, opaque).intGet the chart int width in pixel; to be used by the derived subclass.intGet the chart int width in pixel; to be used by the derived subclass.Returns the legend font of this chart.getModel()Returns the chart model associated with this chart, or null if this chart is not associated with any chart data model.Get the chart orientation (vertical or horizontal)intGet the pane alpha (transparency, 0 ~ 255, opacue).Get the pane color of the chart (in string as #RRGGBB).int[]Get the pane color in int array (0: red, 1: green, 2:blue).Returns the period used in Time Series Chart.Returns the time zone that this Time Series Chart belongs to, or null if the default time zone is used.getTitle()Get the chart's title.Returns the title font of this chart.getType()Get the chart's type.getXAxis()Get the label in xAxis.Returns the label font of x axis of this chart.Returns the tick number font of x axis of this chart.getYAxis()Get the label in yAxis.Returns the label font of y axis of this chart.Returns the tick number font of y axis of this chart.booleanCheck whether show the legend of the chart.booleanCheck whether show the tooltiptext.booleanisThreeD()Whether a 3d chart.protected ChartEngineInstantiates the default chart engine.voidonPageAttached(org.zkoss.zk.ui.Page newpage, org.zkoss.zk.ui.Page oldpage) voidonPageDetached(org.zkoss.zk.ui.Page page) voidsetAreaListener(String clsnm) Sets the renderer by use of a class name.voidsetAreaListener(ChartAreaListener listener) Sets the renderer which is used to render each area.voidsetBgAlpha(int alpha) Set the background alpha (transparency, 0 ~ 255).voidsetBgColor(String color) Set the background color of the chart.voidsetDateFormat(String format) Sets the date format used by date related Chart.voidSets the chart engine by use of a class name.voidsetEngine(ChartEngine engine) Sets the chart engine.voidsetFgAlpha(int alpha) Set the foreground alpha (transparency, 0 ~ 255).voidOverride super class to prepare the int height.voidOverrides the method in HtmlBasedComponent, not to check using hflex and width at the same timevoidsetLegendFont(Font font) Sets the legend font of this chart.voidSets the model by use of a class name.voidsetModel(ChartModel model) Sets the chart model associated with this chart.voidSet the chart orientation.voidsetPaneAlpha(int alpha) Set the pane alpha (transparency, 0 ~ 255).voidsetPaneColor(String color) Set the pane color of the chart.voidSets the period used in Time Series Chart.voidsetShowLegend(boolean showLegend) whether show the chart's legend.voidsetShowTooltiptext(boolean showTooltiptext) whether show the chart's tooltip.voidsetThreeD(boolean b) Set true to show three dimensional graph (If a type of chart got no 3d peer, this is ignored).voidsetTimeZone(TimeZone tzone) Sets the time zone that this Time Series Chart belongs to, or null if the default time zone is used.voidSet the chart's title.voidsetTitleFont(Font font) Sets the title font of this chart.voidSet the chart's type (Chart.PIE, Chart.BAR, Chart.LINE, etc.).voidOverrides the method in HtmlBasedComponent, not to check using vflex and height at the same timevoidOverride super class to prepare the int width.voidSet the label in xAxis.voidsetXAxisFont(Font axisFont) Sets the label font of x axis of this chart.voidsetXAxisTickFont(Font axisTickFont) Sets the tick number font of x axis of this chart.voidSet the label in yAxis.voidsetYAxisFont(Font axisFont) Sets the label font of y axis of this chart.voidsetYAxisTickFont(Font axisTickFont) Sets the tick number font of y axis of this chart.protected voidmark a draw flag to inform that this Chart needs update.Methods inherited from class org.zkoss.zul.Imagemap
beforeChildAdded, isChildableMethods inherited from class org.zkoss.zul.Image
getContent, getExtraCtrl, getHover, getSrc, renderProperties, setContent, setContent, setHover, setHoverContent, setHoverContent, setSrcMethods inherited from class org.zkoss.zul.impl.XulElement
getContext, getCtrlKeys, getPopup, getPropertyAccess, getTooltip, setContext, setContext, setContextAttributes, setCtrlKeys, setPopup, setPopup, setPopupAttributes, setTooltip, setTooltip, setTooltipAttributesMethods inherited from class org.zkoss.zk.ui.HtmlBasedComponent
addSclass, evalCSSFlex, focus, getAction, getClientAction, getDraggable, getDroppable, getHeight, getHflex, getLeft, getRenderdefer, getSclass, getSkeleton, getStyle, getTabindex, getTabindexInteger, getTooltiptext, getTop, getVflex, getWidth, getZclass, getZindex, getZIndex, removeSclass, removeSclass, service, setAction, setClass, setClientAction, setDraggable, setDroppable, setFocus, setHeight0, setHeightDirectly, setHflex0, setHflexDirectly, setLeft, setLeftDirectly, setRenderdefer, setSclass, setSkeleton, setStyle, setTabindex, setTabindex, setTooltiptext, setTop, setTopDirectly, setVflex0, setVflexDirectly, setWidth0, setWidthDirectly, setZclass, setZindex, setZIndex, setZIndexDirectlyMethods inherited from class org.zkoss.zk.ui.AbstractComponent
addAnnotation, addCallback, addClientEvent, addEventHandler, addEventListener, addForward, addForward, addForward, addForward, addMoved, addRedrawCallback, addScopeListener, addShadowRoot, addShadowRootBefore, addSharedEventHandlerMap, appendChild, applyProperties, beforeChildRemoved, beforeParentChanged, destroyIndexCacheMap, detach, didActivate, didActivate, didDeserialize, didDeserialize, disableBindingAnnotation, disableClientUpdate, disableHostChanged, enableBindingAnnotation, enableHostChanged, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttribute, getAttributeOrFellow, getAttributes, getAttributes, getAuService, getAutag, getCallback, getChildren, getClientAttribute, getClientDataAttribute, getClientEvents, getDefaultMold, getDefinition, getDesktop, getEventHandler, getEventHandlerNames, getEventListenerMap, getEventListeners, getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, getFirstChild, getForwards, getId, getIndexCacheMap, getLastChild, getMold, getNextSibling, getPage, getParent, getPreviousSibling, getRedrawCallback, getRoot, getShadowFellowIfAny, getShadowRoots, getShadowVariable, getShadowVariable, getShadowVariable0, getSpaceOwner, getSpecialRendererOutput, getStubonly, getSubBindingAnnotationCount, getTemplate, getTemplateNames, getUuid, getWidgetAttributeNames, getWidgetClass, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttribute, hasAttributeOrFellow, hasBindingAnnotation, hasFellow, hasFellow, hasSubBindingAnnotation, initIndexCacheMap, insertBefore, invalidate, isDisabledHostChanged, isInitialized, isInvalidated, isListenerAvailable, isVisible, onChildAdded, onChildRemoved, onParentChanged, onWrongValue, query, queryAll, redraw, redrawChildren, removeAttribute, removeAttribute, removeAttribute, removeCallback, removeChild, removeEventListener, removeForward, removeForward, removeRedrawCallback, removeScopeListener, removeShadowRoot, render, render, render, renderPropertiesOnly, replace, response, response, response, service, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setAttribute, setAuService, setAutag, setClientAttribute, setClientDataAttribute, setDefinition, setDefinition, setId, setMold, setPage, setPageBefore, setParent, setStubonly, setStubonly, setSubBindingAnnotationCount, setTemplate, setVisible, setVisibleDirectly, setWidgetClass, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, toString, updateByClient, updateSubBindingAnnotationCount, willPassivate, willPassivate, willSerialize, willSerialize
-
Field Details
-
PIE
- See Also:
-
FUNNEL
- See Also:
-
RING
- See Also:
-
BAR
- See Also:
-
LINE
- See Also:
-
AREA
- See Also:
-
STACKED_BAR
- See Also:
-
COMBINATION
- See Also:
-
STACKED_AREA
- See Also:
-
WATERFALL
- See Also:
-
POLAR
- See Also:
-
SCATTER
- See Also:
-
TIME_SERIES
- See Also:
-
STEP
- See Also:
-
STEP_AREA
- See Also:
-
HISTOGRAM
- See Also:
-
CANDLESTICK
- See Also:
-
HIGHLOW
- See Also:
-
BUBBLE
- See Also:
-
WAFERMAP
- See Also:
-
GANTT
- See Also:
-
WIND
- See Also:
-
DIAL
- See Also:
-
YEAR
- See Also:
-
QUARTER
- See Also:
-
MONTH
- See Also:
-
WEEK
- See Also:
-
DAY
- See Also:
-
HOUR
- See Also:
-
MINUTE
- See Also:
-
SECOND
- See Also:
-
MILLISECOND
- See Also:
-
-
Constructor Details
-
Chart
public Chart()
-
-
Method Details
-
setType
Set the chart's type (Chart.PIE, Chart.BAR, Chart.LINE, etc.).Default: pie.
-
getType
Get the chart's type. -
setThreeD
public void setThreeD(boolean b) Set true to show three dimensional graph (If a type of chart got no 3d peer, this is ignored). -
isThreeD
public boolean isThreeD()Whether a 3d chart. -
setTitle
Set the chart's title.- Parameters:
title- the chart's title.
-
getTitle
Get the chart's title. -
setWidth
Override super class to prepare the int width.- Overrides:
setWidthin classorg.zkoss.zk.ui.HtmlBasedComponent
-
setHflex
Overrides the method in HtmlBasedComponent, not to check using hflex and width at the same time- Overrides:
setHflexin classorg.zkoss.zk.ui.HtmlBasedComponent- Since:
- 8.0.1
-
getIntWidth
public int getIntWidth()Get the chart int width in pixel; to be used by the derived subclass. -
setHeight
Override super class to prepare the int height.- Overrides:
setHeightin classorg.zkoss.zk.ui.HtmlBasedComponent
-
setVflex
Overrides the method in HtmlBasedComponent, not to check using vflex and height at the same time- Overrides:
setVflexin classorg.zkoss.zk.ui.HtmlBasedComponent- Since:
- 8.0.1
-
getIntHeight
public int getIntHeight()Get the chart int width in pixel; to be used by the derived subclass. -
setXAxis
Set the label in xAxis.- Parameters:
label- label in xAxis.
-
getXAxis
Get the label in xAxis. -
setYAxis
Set the label in yAxis.- Parameters:
label- label in yAxis.
-
getYAxis
Get the label in yAxis. -
setShowLegend
public void setShowLegend(boolean showLegend) whether show the chart's legend.- Parameters:
showLegend- true if want to show the legend (default to true).
-
isShowLegend
public boolean isShowLegend()Check whether show the legend of the chart. -
setShowTooltiptext
public void setShowTooltiptext(boolean showTooltiptext) whether show the chart's tooltip.- Parameters:
showTooltiptext- true if want to pop the tooltiptext (default to true).
-
isShowTooltiptext
public boolean isShowTooltiptext()Check whether show the tooltiptext. -
setPaneAlpha
public void setPaneAlpha(int alpha) Set the pane alpha (transparency, 0 ~ 255).- Parameters:
alpha- the transparency of pane color (0 ~ 255, default to 255 opaque).
-
getPaneAlpha
public int getPaneAlpha()Get the pane alpha (transparency, 0 ~ 255, opacue). -
setPaneColor
Set the pane color of the chart.- Parameters:
color- in #RRGGBB format (hexadecimal).
-
getPaneColor
Get the pane color of the chart (in string as #RRGGBB). null means default. -
getPaneRGB
public int[] getPaneRGB()Get the pane color in int array (0: red, 1: green, 2:blue). null means default. -
setFgAlpha
public void setFgAlpha(int alpha) Set the foreground alpha (transparency, 0 ~ 255).- Parameters:
alpha- the transparency of foreground color (0 ~ 255, default to 255 opaque).
-
getFgAlpha
public int getFgAlpha()Get the foreground alpha (transparency, 0 ~ 255, opaque). -
setBgAlpha
public void setBgAlpha(int alpha) Set the background alpha (transparency, 0 ~ 255).- Parameters:
alpha- the transparency of background color (0 ~ 255, default to 255 opaque).
-
getBgAlpha
public int getBgAlpha()Get the background alpha (transparency, 0 ~ 255, opaque). -
setBgColor
Set the background color of the chart.- Parameters:
color- in #RRGGBB format (hexadecimal).
-
getBgColor
Get the background color of the chart (in string as #RRGGBB). null means default. -
getBgRGB
public int[] getBgRGB()Get the background color in int array (0: red, 1: green, 2:blue). null means default. -
setOrient
Set the chart orientation.- Parameters:
orient- vertical or horizontal (default to vertical)
-
getOrient
Get the chart orientation (vertical or horizontal) -
getTimeZone
Returns the time zone that this Time Series Chart belongs to, or null if the default time zone is used.The default time zone is determined by
TimeZones.getCurrent(). -
setTimeZone
Sets the time zone that this Time Series Chart belongs to, or null if the default time zone is used.The default time zone is determined by
TimeZones.getCurrent(). -
getPeriod
Returns the period used in Time Series Chart. The value can be "millisecond", "second", "minute", "hour", "day", "week", "month", "quarter", and "year". default is "millisecond" if not specified. -
setPeriod
Sets the period used in Time Series Chart. The value can be "millisecond", "second", "minute", "hour", "day", "week", "month", "quarter", and "year". -
getDateFormat
Returns the date format used by date related Chart.- Returns:
- the date format used by date related Chart..
-
setDateFormat
Sets the date format used by date related Chart.- Parameters:
format-
-
getModel
Returns the chart model associated with this chart, or null if this chart is not associated with any chart data model. -
setModel
Sets the chart model associated with this chart. If a non-null model is assigned, no matter whether it is the same as the previous, it will always cause re-render.- Parameters:
model- the chart model to associate, or null to dissociate any previous model.- Throws:
org.zkoss.zk.ui.UiException- if failed to initialize with the model
-
setModel
public void setModel(String clsnm) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InstantiationException, InvocationTargetException Sets the model by use of a class name. It creates an instance automatically. -
getTitleFont
Returns the title font of this chart. If you saw squares rather than correct words in title, check whether the default title font supports your characters (e.g. Chinese). You probably have to set this font accordingly.- Returns:
- the title font
-
setTitleFont
Sets the title font of this chart. If you saw squares rather than correct words in title, check whether the default title font supports your characters (e.g. Chinese). You probably have to set this font accordingly.- Parameters:
font- the title font of this chart
-
getLegendFont
Returns the legend font of this chart. If you saw squares rather than correct words in legend, check whether the default legend font supports your characters (e.g. Chinese). You probably have to set this font accordingly.- Returns:
- the title font
-
setLegendFont
Sets the legend font of this chart. If you saw squares rather than correct words in legend, check whether the default legend font supports your characters (e.g. Chinese). You probably have to set this font accordingly.- Parameters:
font- the legend font of this chart
-
getXAxisTickFont
Returns the tick number font of x axis of this chart. If you saw squares rather than correct words in x axis tick, check whether the default x axis tick font supports your characters (e.g. Chinese). You probably have to set this font accordingly.- Returns:
- the tick number font of x axis of this chart
-
setXAxisTickFont
Sets the tick number font of x axis of this chart. If you saw squares rather than correct words in x axis tick, check whether the default x axis tick font supports your characters (e.g. Chinese). You probably have to set this font accordingly.- Parameters:
axisTickFont- the tick number font of x axis of this chart
-
getXAxisFont
Returns the label font of x axis of this chart. If you saw squares rather than correct words in x axis label, check whether the default x axis label font supports your characters (e.g. Chinese). You probably have to set this font accordingly.- Returns:
- the label font of x axis of this chart
-
setXAxisFont
Sets the label font of x axis of this chart. If you saw squares rather than correct words in x axis label, check whether the default x axis label font supports your characters (e.g. Chinese). You probably have to set this font accordingly.- Parameters:
axisFont- the label font of x axis of this chart
-
getYAxisTickFont
Returns the tick number font of y axis of this chart. If you saw squares rather than correct words in y axis tick, check whether the default y axis tick font supports your characters (e.g. Chinese). You probably have to set this font accordingly.- Returns:
- the tick number font of y axis of this chart
-
setYAxisTickFont
Sets the tick number font of y axis of this chart. If you saw squares rather than correct words in y axis tick, check whether the default y axis tick font supports your characters (e.g. Chinese). You probably have to set this font accordingly.- Parameters:
axisTickFont- the tick number font of y axis of this chart
-
getYAxisFont
Returns the label font of y axis of this chart. If you saw squares rather than correct words in y axis label, check whether the default y axis label font supports your characters (e.g. Chinese). You probably have to set this font accordingly.- Returns:
- the label font of y axis of this chart
-
setYAxisFont
Sets the label font of y axis of this chart. If you saw squares rather than correct words in y axis label, check whether the default y axis label font supports your characters (e.g. Chinese). You probably have to set this font accordingly.- Parameters:
axisFont- the tick number font of y axis of this chart
-
getEngine
Returns the implementation chart engine.- Throws:
org.zkoss.zk.ui.UiException- if failed to load the engine.
-
newChartEngine
Instantiates the default chart engine. It is called, ifsetEngine(org.zkoss.zul.impl.ChartEngine)is not called with non-null engine.By default, it looks up the library property called org.zkoss.zul.chart.engine.class. If found, the value is assumed to be the class name of the chart engine (it must implement
ChartEngine). If not found,UiExceptionis thrown.Derived class might override this method to provide your own default class.
- Throws:
org.zkoss.zk.ui.UiException- if failed to instantiate the engine- Since:
- 3.0.0
-
setEngine
Sets the chart engine. -
setEngine
public void setEngine(String clsnm) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InstantiationException, InvocationTargetException Sets the chart engine by use of a class name. It creates an instance automatically. -
getAreaListener
Returns the renderer to render each area, or null if the default renderer is used. -
setAreaListener
Sets the renderer which is used to render each area.Note: changing a render will not cause the chart to re-render. If you want it to re-render, you could call smartDraw.
- Parameters:
listener- the area listener, or null to ignore it.- Throws:
org.zkoss.zk.ui.UiException- if failed to initialize.
-
setAreaListener
public void setAreaListener(String clsnm) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InstantiationException, InvocationTargetException Sets the renderer by use of a class name. It creates an instance automatically. -
smartDrawChart
protected void smartDrawChart()mark a draw flag to inform that this Chart needs update. -
addEventListener
public boolean addEventListener(String evtnm, org.zkoss.zk.ui.event.EventListener<? extends org.zkoss.zk.ui.event.Event> listener) - Specified by:
addEventListenerin interfaceorg.zkoss.zk.ui.Component- Overrides:
addEventListenerin classorg.zkoss.zk.ui.AbstractComponent
-
clone
- Specified by:
clonein interfaceorg.zkoss.zk.ui.Component- Overrides:
clonein classXulElement
-
onPageAttached
public void onPageAttached(org.zkoss.zk.ui.Page newpage, org.zkoss.zk.ui.Page oldpage) - Specified by:
onPageAttachedin interfaceorg.zkoss.zk.ui.sys.ComponentCtrl- Overrides:
onPageAttachedin classorg.zkoss.zk.ui.AbstractComponent
-
onPageDetached
public void onPageDetached(org.zkoss.zk.ui.Page page) - Specified by:
onPageDetachedin interfaceorg.zkoss.zk.ui.sys.ComponentCtrl- Overrides:
onPageDetachedin classorg.zkoss.zk.ui.AbstractComponent
-