Class StackLabels
- java.lang.Object
-
- org.zkoss.chart.Optionable
-
- org.zkoss.chart.StackLabels
-
- All Implemented Interfaces:
Serializable
,OptionDataListener
,org.zkoss.json.JSONAware
public class StackLabels extends Optionable
The stack labels show the total value for each bar in a stacked column or bar chart. The label will be placed on top of positive columns and below negative columns. In case of an inverted column chart or a bar chart the label is placed to the right of positive bars and to the left of negative bars.All the options in this class support
DynamicalAttribute
.- Author:
- jumperchen, RaymondChao
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.zkoss.chart.Optionable
NOT_NULL_VALUE, options
-
-
Constructor Summary
Constructors Constructor Description StackLabels()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getAlign()
Returns the horizontal alignment of the stack total label.String
getFormat()
Returns a format string for the data label.Number
getRotation()
Returns rotation of the labels in degrees.<K,V>
Map<K,V>getStyle()
Returns CSS styles for the label.String
getTextAlign()
Returns the text alignment for the label.String
getVerticalAlign()
Returns defines the vertical alignment of the stack total label.Number
getX()
Returns the x position offset of the label relative to the left of the stacked bar.Number
getY()
Returns the y position offset of the label relative to the tick position on the axis.boolean
isEnabled()
Returns whether to enable or disable the stack total labels.boolean
isUseHTML()
Returns whether to use HTML to render the labels.void
setAlign(String align)
Sets the horizontal alignment of the stack total label.void
setEnabled(boolean enabled)
Sets whether to enable or disable the stack total labels.void
setFormat(String format)
Sets a format string for the data label.void
setRotation(Number rotation)
Sets rotation of the labels in degrees.void
setStyle(String style)
Sets CSS styles for the label.<K,V>
voidsetStyle(Map<K,V> style)
Sets CSS styles for the label.void
setTextAlign(String textAlign)
Sets the text alignment for the label.void
setUseHTML(boolean useHTML)
Sets whether to use HTML to render the labels.void
setVerticalAlign(String verticalAlign)
Sets defines the vertical alignment of the stack total label.void
setX(Number x)
Sets the x position offset of the label relative to the left of the stacked bar.void
setY(Number y)
Sets the y position offset of the label relative to the tick position on the axis.-
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
-
getAlign
public String getAlign()
Returns the horizontal alignment of the stack total label. Can be one of"left"
,"center"
or"right"
. The default value is calculated at runtime and depends on orientation and whether the stack is positive or negative.Default: null.
-
setAlign
public void setAlign(String align)
Sets the horizontal alignment of the stack total label. Can be one of"left"
,"center"
or"right"
. The default value is calculated at runtime and depends on orientation and whether the stack is positive or negative.
-
isEnabled
public boolean isEnabled()
Returns whether to enable or disable the stack total labels.Default: false.
-
setEnabled
public void setEnabled(boolean enabled)
Sets whether to enable or disable the stack total labels.
-
getFormat
public String getFormat()
Returns a format string for the data label. Available variables are the same as forformatter
.Default: "{total}".
-
setFormat
public void setFormat(String format)
Sets a format string for the data label. Available variables are the same as forformatter
.Default: "{total}".
-
getRotation
public Number getRotation()
Returns rotation of the labels in degrees.Default: 0.
-
setRotation
public void setRotation(Number rotation)
Sets rotation of the labels in degrees.
-
getStyle
public <K,V> Map<K,V> getStyle()
Returns CSS styles for the label.Defaults to:
color: #666; font-size: 11px; line-height: 14px;
- 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 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 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
-
getTextAlign
public String getTextAlign()
Returns the text alignment for the label. Whilealign
determines where the texts anchor point is placed with regards to the stack,textAlign
determines how the text is aligned against its anchor point. Possible values are"left"
,"center"
and"right"
. The default value is calculated at runtime and depends on orientation and whether the stack is positive or negative.Default: null.
-
setTextAlign
public void setTextAlign(String textAlign)
Sets the text alignment for the label. Whilealign
determines where the texts anchor point is placed with regards to the stack,textAlign
determines how the text is aligned against its anchor point. Possible values are"left"
,"center"
and"right"
. The default value is calculated at runtime and depends on orientation and whether the stack is positive or negative.Default: null.
-
isUseHTML
public boolean isUseHTML()
Returns whether to use HTML to render the labels.Default: false.
-
setUseHTML
public void setUseHTML(boolean useHTML)
Sets whether to use HTML to render the labels.
-
getVerticalAlign
public String getVerticalAlign()
Returns defines the vertical alignment of the stack total label. Can be one of"top"
,"middle"
or"bottom"
. The default value is calculated at runtime and depends on orientation and whether the stack is positive or negative.Default: null.
-
setVerticalAlign
public void setVerticalAlign(String verticalAlign)
Sets defines the vertical alignment of the stack total label. Can be one of"top"
,"middle"
or"bottom"
. The default value is calculated at runtime and depends on orientation and whether the stack is positive or negative.
-
getX
public Number getX()
Returns the x position offset of the label relative to the left of the stacked bar. The default value is calculated at runtime and depends on orientation and whether the stack is positive or negative.Default: null.
-
setX
public void setX(Number x)
Sets the x position offset of the label relative to the left of the stacked bar. The default value is calculated at runtime and depends on orientation and whether the stack is positive or negative.
-
getY
public Number getY()
Returns the y position offset of the label relative to the tick position on the axis. The default value is calculated at runtime and depends on orientation and whether the stack is positive or negative.Default: null.
-
setY
public void setY(Number y)
Sets the y position offset of the label relative to the tick position on the axis. The default value is calculated at runtime and depends on orientation and whether the stack is positive or negative.
-
-