Package com.storedobject.chart
Class Chart.Label
java.lang.Object
com.storedobject.chart.TextStyle
com.storedobject.chart.AbstractLabel
com.storedobject.chart.Label
com.storedobject.chart.Chart.Label
- All Implemented Interfaces:
ComponentProperty,VisibleProperty
- Enclosing class:
Chart
Value-label that can be customized for a chart.
- 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.protected StringName of the gap to be used when rendering (It is different when different parts are used).Get the position indicator of this label.voidsetFormatter(String formatter) Set the label formatter.voidsetLabelProvider(AbstractDataProvider<?> labels) Instead of specifying the format for the label viasetFormatter(String), it is possible to set the labels directly from anAbstractDataProviderusing this method.Methods inherited from class com.storedobject.chart.Label
getFormatter, getRotation, isInside, setInside, setRotationMethods inherited from class com.storedobject.chart.AbstractLabel
getGap, 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
-
getGapName
Description copied from class:AbstractLabelName of the gap to be used when rendering (It is different when different parts are used).- Overrides:
getGapNamein classAbstractLabel- Returns:
- Name of the gap.
-
setFormatter
Set the label formatter.Format template may contain patterns like {n} where "n" is the index of the axis. So {0} represents the x-axis value and {1} represents the y-axis value for an
XYChart. If 2 y-axes are there, it will be {1} and {2} respectively. There can be many axes and the index value will increase accordingly. The index indicates the order in which the axes were added to the chart.You could also use {D:data name} to specify any data set so that the labels will be taken from the data set specified. This mechanism is useful when you have a confusing set of axes and could not precisely determine the index number of the axis. Also, please see if you can use
setLabelProvider(AbstractDataProvider)instead of this.Examples: "{0}, {1}" => Produces labels like "Rice 20" where "Rice" is the x-value and 20 is the y-value. "{1} kg" => Produces labels like "20 kg" where 20 is the y-value. "{1} kg/year of {chart}" => Produces labels like "4000 kg/year of Rice" where 4000 is the y-value and "Rice" is the name of the chart.- Specified by:
setFormatterin classLabel- Parameters:
formatter- Label formatter to be set.
-
setLabelProvider
Instead of specifying the format for the label viasetFormatter(String), it is possible to set the labels directly from anAbstractDataProviderusing this method. Such anAbstractDataProvidermay be created from the one or more of theAbstractDataProviders involved via one of the create methods:AbstractDataProvider.create(DataType, Function)orAbstractDataProvider.create(DataType, BiFunction)- Parameters:
labels- Labels to be set from the elements of this data provider. (Typically aCategoryDatais used).
-
getPosition
Get the position indicator of this label.- Returns:
- Label position.
-
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.
-