Package com.storedobject.chart
Class Axis.Label
java.lang.Object
com.storedobject.chart.TextStyle
com.storedobject.chart.AbstractLabel
com.storedobject.chart.Label
com.storedobject.chart.Axis.Label
- All Implemented Interfaces:
ComponentProperty,VisibleProperty
- Enclosing class:
Axis
Represents the label used by
Axis.- Author:
- Syam
-
Field Summary
Fields inherited from class com.storedobject.chart.Label
doNotEscapeFormat, formatParser, formatter -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidEncode the JSON string with the properties of this.final intGet the interval between labels.final BooleanCheck if a label for the maximum value will be displayed or not.final BooleanCheck if a label for the minimum value will be displayed or not.voidsetFormatter(String formatter) Set the label formatter.voidsetFormatterFunction(String function) Set a JavaScript function as the label formatter.voidsetInterval(int interval) Set the interval between labels.voidsetShowMaxLabel(Boolean showMaxLabel) Setting for displaying the label corresponding to the maximum value.voidsetShowMinLabel(Boolean showMinLabel) Setting for displaying the label corresponding to the minimum value.Methods inherited from class com.storedobject.chart.Label
getFormatter, getRotation, isInside, setInside, setRotationMethods inherited from class com.storedobject.chart.AbstractLabel
getGap, getGapName, isVisible, setGap, setVisibleMethods inherited from class com.storedobject.chart.TextStyle
getAlignment, getBackground, getBorder, getColor, getFontStyle, getPadding, getRichTextStyle, getTextBorder, setAlignment, setBackground, setBorder, setColor, setFontStyle, setPadding, setRichTextStyle, setTextBorderMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.storedobject.chart.VisibleProperty
hide, show
-
Constructor Details
-
Label
public Label()Constructor.
-
-
Method Details
-
encodeJSON
Description copied from interface:ComponentPropertyEncode the JSON string with the properties of this.- Specified by:
encodeJSONin interfaceComponentProperty- Overrides:
encodeJSONin classLabel- Parameters:
sb- Encoded JSON string to be appended to this.
-
getShowMaxLabel
Check if a label for the maximum value will be displayed or not.- Returns:
- True or false.
Nullvalue means that it will be determined automatically to eliminate labels-overlap.
-
setShowMaxLabel
Setting for displaying the label corresponding to the maximum value.- Parameters:
showMaxLabel- True or false.Nullvalue means that it will be determined automatically to eliminate labels-overlap.
-
getShowMinLabel
Check if a label for the minimum value will be displayed or not.- Returns:
- True or false.
Nullvalue means that it will be determined automatically to eliminate labels-overlap.
-
setShowMinLabel
Setting for displaying the label corresponding to the minimum value.- Parameters:
showMinLabel- True or false.Nullvalue means that it will be determined automatically to eliminate labels-overlap.
-
getInterval
public final int getInterval()Get the interval between labels.- Returns:
- Interval.
-
setInterval
public void setInterval(int interval) Set the interval between labels.Important Note: This is applicable only for
DataType.CATEGORY.- Parameters:
interval- 0 means all labels, 1 means every alternate label, 2 means every 2nd label and so on. A special value of -1 means labeling will be determined automatically to remove overlap.
-
setFormatter
Set the label formatter.Example (numeric values): "{value} kg" => Produces labels like "20 kg" Examples (date/time values): "{yyyy}-{MM}-{dd}" => Produces labels like "1998-01-23" "Day {d}" => Produces labels like "Day 1" All date/time value formatting characters: {yyyy} => years (2020, 2021 etc.) {yy} => years (20, 21 etc.) {Q} => quarter {1, 2, 3 etc.} {MMMM} => dull name of the month (January, February etc.) {MMM} => short name of the month (Jan, Feb etc.) {MM} => 2 digits of the month (01, 02, 03 etc.) {M} => 1/2 digits of the month (1, 2, 3 etc.) {dd} => 2 digits day of the month (01, 02, 03 etc.) {d} => 1/2 digits day of the month (8, 9, 10, 11 etc.) {eeee} => day of week - full name (Monday, Tuesday etc.) {ee} => day of week - short name (Mon, Tue etc.) {e} => day of week (1 to 54) {HH} => Hour (00-23) {H} => Hour (0-23) {hh} => Hour (00-12) {h} => Hour (1-12) {mm} => Minute {00-59} {m} => Minute {0-59} {ss} => Second {00-59} {s} => Second {0-59} {SSS} => Second {000-999} {S} => Second {0-999}- Specified by:
setFormatterin classLabel- Parameters:
formatter- Label formatter to be set.
-
setFormatterFunction
Set a JavaScript function as the label formatter. Only the body of the JavaScript function needs to be set. Two parameters, (value, index) are passed to the function - value: The value at that axis-tick, index: The index is the axis-tick index (index is of not much use since it is not the index of the data). The function should return the label to be displayed.Example: For displaying a rounded numeric value (rounded to 2 decimal places) in a numeric axis, you may do something like:
setFormatterFunction("return value.toFixed(2);");- Parameters:
function- The body of the JavaScript function.
-