Class AxisTitle
- java.lang.Object
-
- org.zkoss.chart.Optionable
-
- org.zkoss.chart.AxisTitle
-
- All Implemented Interfaces:
Serializable
,OptionDataListener
,org.zkoss.json.JSONAware
- Direct Known Subclasses:
YAxisTitle
public class AxisTitle extends Optionable
An option for axis' titleAll the options in this class support
DynamicalAttribute
.- Author:
- jumperchen
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.zkoss.chart.Optionable
NOT_NULL_VALUE, options
-
-
Constructor Summary
Constructors Constructor Description AxisTitle()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description String
getAlign()
Returns alignment of the title relative to the axis values.Number
getMargin()
Returns the pixel distance between the axis labels or line and the title.Number
getOffset()
Returns the distance of the axis title from the axis line.String
getPosition3d()
Returns how the title is repositioned according to the 3D chart orientation.Number
getRotation()
Returns the rotation of the text in degrees.<K,V>
Map<K,V>getStyle()
Returns CSS styles for the title.String
getText()
Returns the actual text of the axis title.String
getTextAlign()
Returns the alignment of the text, can be"left"
,"right"
or"center"
.Number
getX()
Returns the x offset.Number
getY()
Returns the y offset.boolean
isEnabled()
Deprecated.boolean
isReserveSpace()
Returns whether to reserve space for the title when laying out the axis.Boolean
isSkew3d()
Returns whether the axis title will skewed to follow the perspective.boolean
isUseHTML()
Returns whether to use HTML to render the axis title.void
setAlign(String align)
Sets alignment of the title relative to the axis values.void
setEnabled(boolean enabled)
Deprecated.void
setMargin(Number margin)
Sets the pixel distance between the axis labels or line and the title.void
setOffset(Number offset)
Sets the distance of the axis title from the axis line.void
setPosition3d(String position3d)
Sets how the title is repositioned according to the 3D chart orientation.void
setReserveSpace(boolean reserveSpace)
Sets whether to reserve space for the title when laying out the axis.void
setRotation(Number rotation)
Sets the rotation of the text in degrees.void
setSkew3d(Boolean skew3d)
Sets whether the axis title will skewed to follow the perspective.void
setStyle(String style)
Sets CSS styles for the title.<K,V>
voidsetStyle(Map<K,V> style)
Sets CSS styles for the title.void
setText(String text)
Sets the actual text of the axis title.void
setTextAlign(String textAlign)
Sets the alignment of the text, can be"left"
,"right"
or"center"
.void
setUseHTML(boolean useHTML)
Sets whether to use HTML to render the axis title.void
setX(Number x)
Sets the x offset.void
setY(Number y)
Sets the y offset.-
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 alignment of the title relative to the axis values. Possible values are "low", "middle" or "high".Default: "middle".
-
setAlign
public void setAlign(String align)
Sets alignment of the title relative to the axis values. Possible values are "low", "middle" or "high".
-
isEnabled
@Deprecated public boolean isEnabled()
Deprecated.Returns enable or disable the title.Default: null
-
setEnabled
@Deprecated public void setEnabled(boolean enabled)
Deprecated.Sets enable or disable the title.
-
getMargin
public Number getMargin()
Returns the pixel distance between the axis labels or line and the title. Defaults to 0 for horizontal axes, 10 for verticalDefault: 0.
-
setMargin
public void setMargin(Number margin)
Sets the pixel distance between the axis labels or line and the title. Defaults to 0 for horizontal axes, 10 for vertical
-
getOffset
public Number getOffset()
Returns the distance of the axis title from the axis line. By default, this distance is computed from the offset width of the labels, the labels' distance from the axis and the title's margin. However when the offset option is set, it overrides all this.Default: null.
-
setOffset
public void setOffset(Number offset)
Sets the distance of the axis title from the axis line. By default, this distance is computed from the offset width of the labels, the labels' distance from the axis and the title's margin. However when the offset option is set, it overrides all this.
-
getPosition3d
public String getPosition3d()
Returns how the title is repositioned according to the 3D chart orientation.Default:
null
- Since:
- 10.2.1.0
-
setPosition3d
public void setPosition3d(String position3d)
Sets how the title is repositioned according to the 3D chart orientation.-
"offset"
: Maintain a fixed horizontal/vertical distance from the tick marks, despite the chart orientation. This is the backwards compatible behavior, and causes skewing of X and Z axes. -
"chart"
: Preserve 3D position relative to the chart. This looks nice, but hard to read if the text isn't forward-facing. -
"flap"
: Rotated text along the axis to compensate for the chart orientation. This tries to maintain text as legible as possible on all orientations. -
"ortho"
: Rotated text along the axis direction so that the labels are orthogonal to the axis. This is very similar to 'flap', but prevents skewing the labels (X and Y scaling are still present). -
null
: Will use the config fromAxisLabels.setPosition3D(String)
Default:
null
- Since:
- 10.2.1.0
-
-
isReserveSpace
public boolean isReserveSpace()
Returns whether to reserve space for the title when laying out the axis.Default:
true
- Since:
- 10.2.1.0
-
setReserveSpace
public void setReserveSpace(boolean reserveSpace)
Sets whether to reserve space for the title when laying out the axis.Default:
true
- Since:
- 10.2.1.0
-
getRotation
public Number getRotation()
Returns the rotation of the text in degrees. 0 is horizontal, 270 is vertical reading from bottom to top.Default: 0.
- Returns:
- rotation the rotation of the text in degrees
-
setRotation
public void setRotation(Number rotation)
Sets the rotation of the text in degrees. 0 is horizontal, 270 is vertical reading from bottom to top.
-
isSkew3d
public Boolean isSkew3d()
Returns whether the axis title will skewed to follow the perspective.Default:
null
- Since:
- 10.2.1.0
-
setSkew3d
public void setSkew3d(Boolean skew3d)
Sets whether the axis title will skewed to follow the perspective.This will fix overlapping labels and titles, but texts become less legible due to the distortion.
The final appearance depends heavily on
setPosition3d(String)
.A null value will use the config from
AxisLabels.setSkew3D(boolean)
.Default:
null
- Since:
- 10.2.1.0
-
getStyle
public <K,V> Map<K,V> getStyle()
Returns CSS styles for the title. When titles are rotated they are rendered using vector graphic techniques and not all styles are applicable.Default:
color: #6D869F; fontWeight: bold;
- 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 title. When titles are rotated they are rendered using vector graphic techniques and not all styles are applicable.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 title. When titles are rotated they are rendered using vector graphic techniques and not all styles are applicable.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()
Returns the actual text of the axis title. It can contain basic HTML text markup like <b>, <i> and spans with style.Default: null.
-
setText
public void setText(String text)
Sets the actual text of the axis title. It can contain basic HTML text markup like <b>, <i> and spans with style.
-
getTextAlign
public String getTextAlign()
Returns the alignment of the text, can be"left"
,"right"
or"center"
. Default alignment depends on thegetAlign()
Default:
null
- Since:
- 10.2.1.0
-
setTextAlign
public void setTextAlign(String textAlign)
Sets the alignment of the text, can be"left"
,"right"
or"center"
. Default alignment depends on thegetAlign()
:Horizontal axes:
- for align = "low", textAlign is set to left
- for align = "middle", textAlign is set to center
- for align = "high", textAlign is set to right
Vertical axes:
- for align = "low" and opposite = true, textAlign is set to right
- for align = "low" and opposite = false, textAlign is set to left
- for align = "middle", textAlign is set to center
- for align = "high" and opposite = true textAlign is set to left
- for align = "high" and opposite = false textAlign is set to right
Default:
null
- Since:
- 10.2.1.0
-
isUseHTML
public boolean isUseHTML()
Returns whether to use HTML to render the axis title.Default:
false
- Since:
- 10.2.1.0
-
setUseHTML
public void setUseHTML(boolean useHTML)
Sets whether to use HTML to render the axis title.- Since:
- 10.2.1.0
-
getX
public Number getX()
Returns the x offset.
-
setX
public void setX(Number x)
Sets the x offset.
-
getY
public Number getY()
Returns the y offset.
-
setY
public void setY(Number y)
Sets the y offset.
-
-