Class AnnotationLabelOptions
- java.lang.Object
-
- org.zkoss.chart.Optionable
-
- org.zkoss.chart.AnnotationLabelOptions
-
- All Implemented Interfaces:
Serializable
,OptionDataListener
,org.zkoss.json.JSONAware
- Direct Known Subclasses:
AnnotationLabel
public class AnnotationLabelOptions extends Optionable
Options for annotation's labels. Each label inherits options from the labelOptions object. An option from the labelOptions can be overwritten by config for a specific label.All the options in this class support
DynamicalAttribute
.- Since:
- 7.2.1.0
- Author:
- rudyhuang
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.zkoss.chart.Optionable
NOT_NULL_VALUE, options
-
-
Constructor Summary
Constructors Constructor Description AnnotationLabelOptions()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AnnotationLabelAccessibility
getAccessibility()
Returns an accessibility options for annotation label, if null, it will create new one.String
getAlign()
Returns the alignment of the annotation's label.Color
getBackgroundColor()
Returns the background color or gradient for the annotation's label.Color
getBorderColor()
Returns the border color for the annotation's label.Object
getBorderRadius()
Returns the border radius in pixels for the annotation's label.Number
getBorderWidth()
Returns the border width in pixels for the annotation's labelString
getClassName()
Returns class name for styling by CSS.Number
getDistance()
Returns the label's pixel distance from the point.String
getFormat()
Returns the format string for the data label.org.zkoss.json.JavaScriptValue
getFormatter()
Returns the callback JavaScript function to format the annotation's label.String
getOverflow()
Returns how to handle the annotation's label that flow outside the plot area.Number
getPadding()
Returns the padding within the box when either thegetBorderWidth()
or thegetBackgroundColor()
is set.Object
getPoint()
Returns the point which the label will be connected.Shadow
getShadow()
Returns whether to apply a shadow of the box.String
getShape()
Returns the name of a symbol to use for the border around the label.<K,V>
Map<K,V>getStyle()
Returns CSS styles for the annotation's label.String
getText()
Alias for the format option.String
getVerticalAlign()
Returns the vertical alignment of the annotation's label.Number
getX()
Returns the x position offset of the label relative to the point.Number
getY()
Returns the y position offset of the label relative to the point.boolean
isAllowOverlap()
Returns whether to allow the annotation's labels to overlap.boolean
isCrop()
Returns whether to hide the annotation's label that is outside the plot area.boolean
isShadow()
Returns whether to apply a drop shadow to the outer chart area.boolean
isUseHTML()
Returns whether to use HTML to render the annotation's label.void
setAccessibility(AnnotationLabelAccessibility accessibility)
Sets an accessibility options for annotation label.void
setAlign(String align)
Sets the alignment of the annotation's label.void
setAllowOverlap(Boolean allowOverlap)
Sets whether to allow the annotation's labels to overlap.void
setBackgroundColor(String color)
Sets the background color or gradient for the annotation's label.void
setBackgroundColor(Color color)
Sets the background color or gradient for the annotation's label.void
setBackgroundColor(LinearGradient color)
Sets the background color or gradient for the annotation's label.void
setBackgroundColor(RadialGradient color)
Sets the background color or gradient for the annotation's label.void
setBorderColor(String color)
Sets the border color for the annotation's label.void
setBorderColor(Color color)
Sets the border color for the annotation's label.void
setBorderRadius(Number borderRadius)
Sets the border radius in pixels for the annotation's label.void
setBorderRadius(String borderRadius)
Sets the border radius in pixels for the annotation's label.void
setBorderWidth(Number borderWidth)
Sets the border width in pixels for the annotation's labelvoid
setClassName(String className)
Sets class name for styling by CSS.void
setCrop(boolean crop)
Sets whether to hide the annotation's label that is outside the plot area.void
setDistance(Number distance)
Sets the label's pixel distance from the point.void
setFormat(String format)
Sets the format string for the data label.void
setFormatter(org.zkoss.json.JavaScriptValue formatter)
Sets the callback JavaScript function to format the annotation's label.void
setOverflow(String overflow)
Sets how to handle the annotation's label that flow outside the plot area.void
setPadding(int padding)
Sets the padding within the box when either thegetBorderWidth()
or thegetBackgroundColor()
is set.void
setPoint(String pointId)
Sets the id of the point which the label will be connected.void
setPoint(Annotation.Point point)
Sets the point which the label will be connected.void
setShadow(boolean shadow)
Sets whether to apply a shadow of the box.void
setShadow(Shadow shadow)
Sets whether to apply a shadow of the box.void
setShape(String shape)
Sets the name of a symbol to use for the border around the label.void
setStyle(String style)
Sets CSS styles for the annotation's label.<K,V>
voidsetStyle(Map<K,V> style)
Sets CSS styles for the annotation's label.void
setText(String text)
Alias for the format option.void
setUseHTML(boolean useHTML)
Sets whether to use HTML to render the annotation's label.void
setVerticalAlign(String verticalAlign)
Sets the vertical alignment of the annotation's label.void
setX(Number x)
Sets the x position offset of the label relative to the point.void
setY(Number y)
Sets the y position offset of the label relative to the point.-
Methods inherited from class org.zkoss.chart.Optionable
addExtraAttr, addOptionDataListener, clearOptonDataListener, clone, containsKey, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, getAttr, getAttr, getClientState, getExtraAttr, merge, onChange, removeExtraAttr, removeKey, removeOptionDataListener, setAttr, setAttr, setAttr, setAttr, toJSONString, toString
-
-
-
-
Method Detail
-
getAccessibility
public AnnotationLabelAccessibility getAccessibility()
Returns an accessibility options for annotation label, if null, it will create new one.- Since:
- 10.2.1.0
-
setAccessibility
public void setAccessibility(AnnotationLabelAccessibility accessibility)
Sets an accessibility options for annotation label.- Since:
- 10.2.1.0
-
getAlign
public String getAlign()
Returns the alignment of the annotation's label. If right, the right side of the label should be touching the point.Default: "center"
-
setAlign
public void setAlign(String align)
Sets the alignment of the annotation's label. If right, the right side of the label should be touching the point.
-
isAllowOverlap
public boolean isAllowOverlap()
Returns whether to allow the annotation's labels to overlap. To make the labels less sensitive for overlapping, the padding can be set to 0.Default: false.
-
setAllowOverlap
public void setAllowOverlap(Boolean allowOverlap)
Sets whether to allow the annotation's labels to overlap. To make the labels less sensitive for overlapping, the padding can be set to 0.
-
getBackgroundColor
public Color getBackgroundColor()
Returns the background color or gradient for the annotation's label.Default: rgba(0, 0, 0, 0.75)
-
setBackgroundColor
public void setBackgroundColor(Color color)
Sets the background color or gradient for the annotation's label.
-
setBackgroundColor
public void setBackgroundColor(String color)
Sets the background color or gradient for the annotation's label.
-
setBackgroundColor
public void setBackgroundColor(LinearGradient color)
Sets the background color or gradient for the annotation's label.
-
setBackgroundColor
public void setBackgroundColor(RadialGradient color)
Sets the background color or gradient for the annotation's label.
-
getBorderColor
public Color getBorderColor()
Returns the border color for the annotation's label.Default: "black"
-
setBorderColor
public void setBorderColor(Color color)
Sets the border color for the annotation's label.
-
setBorderColor
public void setBorderColor(String color)
Sets the border color for the annotation's label.
-
getBorderRadius
public Object getBorderRadius()
Returns the border radius in pixels for the annotation's label.Default: 3
-
setBorderRadius
public void setBorderRadius(Number borderRadius)
Sets the border radius in pixels for the annotation's label.
-
setBorderRadius
public void setBorderRadius(String borderRadius)
Sets the border radius in pixels for the annotation's label.
-
getBorderWidth
public Number getBorderWidth()
Returns the border width in pixels for the annotation's labelDefault: 1
-
setBorderWidth
public void setBorderWidth(Number borderWidth)
Sets the border width in pixels for the annotation's label
-
getClassName
public String getClassName()
Returns class name for styling by CSS.Default: ""
-
setClassName
public void setClassName(String className)
Sets class name for styling by CSS.
-
isCrop
public boolean isCrop()
Returns whether to hide the annotation's label that is outside the plot area.Default: false
-
setCrop
public void setCrop(boolean crop)
Sets whether to hide the annotation's label that is outside the plot area.
-
getDistance
public Number getDistance()
Returns the label's pixel distance from the point.Default: null
-
setDistance
public void setDistance(Number distance)
Sets the label's pixel distance from the point.
-
getFormatter
public org.zkoss.json.JavaScriptValue getFormatter()
Returns the callback JavaScript function to format the annotation's label. Note that if a format or text are defined, the format or text take precedence and the formatter is ignored. This refers to a point object.Default:
function () { return defined(this.y) ? this.y : 'Annotation label'; }
-
setFormatter
public void setFormatter(org.zkoss.json.JavaScriptValue formatter)
Sets the callback JavaScript function to format the annotation's label. Note that if a format or text are defined, the format or text take precedence and the formatter is ignored. This refers to a point object.
-
getOverflow
public String getOverflow()
Returns how to handle the annotation's label that flow outside the plot area. The justify option aligns the label inside the plot area.Default: "justify".
-
setOverflow
public void setOverflow(String overflow)
Sets how to handle the annotation's label that flow outside the plot area. The justify option aligns the label inside the plot area.
-
getPadding
public Number getPadding()
Returns the padding within the box when either thegetBorderWidth()
or thegetBackgroundColor()
is set.Default: 5
-
setPadding
public void setPadding(int padding)
Sets the padding within the box when either thegetBorderWidth()
or thegetBackgroundColor()
is set.
-
getPoint
public Object getPoint()
Returns the point which the label will be connected. It can be either the point which exists in the series - it is referenced by the point's id - or a new point with defined x, y properties and optionally axes.
-
setPoint
public void setPoint(Annotation.Point point)
Sets the point which the label will be connected.
-
setPoint
public void setPoint(String pointId)
Sets the id of the point which the label will be connected.
-
isShadow
public boolean isShadow()
Returns whether to apply a drop shadow to the outer chart area. Requires that backgroundColor be set.Default: false.
- See Also:
Shadow
-
getShadow
public Shadow getShadow()
Returns whether to apply a shadow of the box.Default:
Shadow.NONE
.- See Also:
Shadow
-
setShadow
public void setShadow(boolean shadow)
Sets whether to apply a shadow of the box.
-
setShadow
public void setShadow(Shadow shadow)
Sets whether to apply a shadow of the box.- See Also:
Shadow
-
getShape
public String getShape()
Returns the name of a symbol to use for the border around the label. Symbols are predefined functions on the Renderer object.Default: callout
-
setShape
public void setShape(String shape)
Sets the name of a symbol to use for the border around the label. Symbols are predefined functions on the Renderer object.
-
getStyle
public <K,V> Map<K,V> getStyle()
Returns CSS styles for the annotation's label.Default: empty
- Type Parameters:
K
- type for the keyif style was set using
setStyle(String)
, type will be Stringif style was set using
setStyle(Map)
, type will be the same as the type from the key of the mapif style was not set, default style will be applied, and type will be String
V
- type for the valueif style was set using
setStyle(String)
, type will be Stringif style was set using
setStyle(Map)
, type will be the same as the type from the key of the mapif style was not set, default style will be applied, and type will be String
-
setStyle
public void setStyle(String style)
Sets CSS styles for the annotation's label.This method allows simple settings like
label.setStyle("fontWeight: 'bold'; color: 'white'; textShadow: '0px 1px 2px black'");
In the format of CSS key:value, and ";" separating multiple key:value pairs, if you have more a complex CSS styling, we recommend using
setStyle(Map)
- Parameters:
style
- one or many CSS key:value pairs in a single line string format
-
setStyle
public <K,V> void setStyle(Map<K,V> style)
Sets CSS styles for the annotation's label.This method allows complex styling like:
Map<String, Object> styles = new HashMap<String, Object>(); styles.put("fill", "#E8E8EA"); styles.put("stroke", "#6E6E78"); styles.put("stroke-width", "1"); styles.put("r", "0"); Map<String, Object> states = new HashMap<String, Object>(); Map<String, String> hover = new HashMap<String, String>(); hover.put("fill", "#F4F4F6"); hover.put("stroke", "#6E6E78"); hover.put("stroke-width", "1"); hover.put("r", "0"); states.put("hover", hover); styles.put("states", states); Map<String, String> style = new HashMap<String, String>(); style.put("color", "#4D5663"); style.put("fontSize", "12px"); style.put("fontFamily", "'Arial'"); style.put("fontWeight", "normal"); style.put("padding", "10px"); styles.put("style", style);
{ "fill": "#E8E8EA", "stroke": "#6E6E78", "stroke-width": "1", "r": "0", "states": { "hover": { "fill": "#F4F4F6", "stroke": "#6E6E78", "stroke-width": "1", "r": "0" } }, "style": { "color": "#4D5663", "fontSize": "12px", "fontFamily": "'Arial'", "fontWeight": "normal", "padding": "10px" } }
- Type Parameters:
K
- Type for the key, usually StringV
- Type for the value, usually String. For nested maps, use Object or any other type.- Parameters:
style
- the style object
-
getText
public String getText()
Alias for the format option.
-
setText
public void setText(String text)
Alias for the format option.
-
isUseHTML
public boolean isUseHTML()
Returns whether to use HTML to render the annotation's label.Default: false.
-
setUseHTML
public void setUseHTML(boolean useHTML)
Sets whether to use HTML to render the annotation's label.
-
getVerticalAlign
public String getVerticalAlign()
Returns the vertical alignment of the annotation's label.Default: bottom
-
setVerticalAlign
public void setVerticalAlign(String verticalAlign)
Sets the vertical alignment of the annotation's label.
-
getX
public Number getX()
Returns the x position offset of the label relative to the point. Note that if a distance is defined, the distance takes precedence over x and y options.Default: 0
-
setX
public void setX(Number x)
Sets the x position offset of the label relative to the point.
-
getY
public Number getY()
Returns the y position offset of the label relative to the point. Note that if a distance is defined, the distance takes precedence over x and y options.Default: -16
-
setY
public void setY(Number y)
Sets the y position offset of the label relative to the point.
-
-