Class AbstractLegend<T extends AbstractLegend>
- All Implemented Interfaces:
HasMargins<AbstractLegend>
,Serializable
- Direct Known Subclasses:
Legend
,StockLegend
See documentation for properties of AmLegend JS Object.
http://docs.amcharts.com/3/javascriptcharts/AmLegend
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddItems
(LegendItem... items) Adds items.getAlign()
getColor()
getData()
getDivId()
getLeft()
getRight()
getTop()
getWidth()
setAccessibleLabel
(String accessibleLabel) Sets the text which screen readers will read if user rolls-over the element or sets focus on it using tab key (this is possible only if tabIndex property is set to some number).Sets alignment of legend entries.setAutoMargins
(Boolean autoMargins) Set autoMargins to true if you want margins of the legend should be adjusted and made equal to chart's margins.setBackgroundAlpha
(Double backgroundAlpha) Sets opacity of legend's background.setBackgroundColor
(Color backgroundColor) Sets background color.setBorderAlpha
(Double borderAlpha) Sets opacity of chart's border.setBorderColor
(Color borderColor) Sets color of legend's border.Sets distance from bottom of the chart, in pixels if legend position is set to "absolute".Sets text color.void
setCombineLegend
(Boolean combineLegend) Set combineLegend to true if you want to display both legend data and graph’s entries.setData
(List<LegendItem> data) Sets list of legend items.Sets id of a div in case you want the legend to be placed in a separate container.setEnabled
(Boolean enabled) Specifies if legend is enabled or not.setEqualWidths
(Boolean equalWidths) Set equalWidths to false if each of legend entry shouldn't be equal to the most widest entry.setFontSize
(Integer fontSize) Sets font size.setForceWidth
(Boolean forceWidth) Set forceWidth to true if you want the width of legend item labels won't be adjusted.setGradientRotation
(Integer gradientRotation) Sets gradient rotation of the legend.setHorizontalGap
(Integer horizontalGap) Sets horizontal space between legend item and left/right border.setLabelText
(String labelText) Sets the text which will be displayed in the legend.setLabelWidth
(Integer labelWidth) Sets label width.Sets distance from left side of the chart, in pixels.setMarginBottom
(Integer marginBottom) Sets bottom spacing.setMarginLeft
(Integer marginLeft) Sets left-hand spacing.setMarginRight
(Integer marginRight) Sets right-hand spacing.setMarginTop
(Integer marginTop) Sets top spacing.setMarkerBorderAlpha
(Double markerBorderAlpha) Sets marker border opacity.setMarkerBorderColor
(Color markerBorderColor) Sets marker border color.setMarkerBorderThickness
(Integer markerBorderThickness) Sets thickness of the legend border.setMarkerDisabledColor
(Color markerDisabledColor) Sets the color of the disabled marker (when the graph is hidden).setMarkerLabelGap
(Integer markerLabelGap) Sets space between legend marker and legend text, in pixels.setMarkerSize
(Integer markerSize) Sets size of the legend marker (key).setMarkerType
(MarkerType markerType) Sets shape of the legend marker (key).setMaxColumns
(Integer maxColumns) Sets maximum number of columns in the legend.setPeriodValueText
(String periodValueText) Sets the text which will be displayed in the value portion of the legend when user is not hovering above any data point.setPosition
(LegendPosition position) Sets position of a legend.setReversedOrder
(Boolean reversedOrder) Set reversedOrder to true if legend entries should be placed in reversed order.Sets distance from right side of the chart, in pixels if legend position is set to "absolute".setRollOverColor
(Color rollOverColor) Sets legend item text color on roll-over.setRollOverGraphAlpha
(Double rollOverGraphAlpha) Sets the opacity of the non-hovered graphs.setShowEntries
(Boolean showEntries) Set showEntries to false if you want to turn all the legend entries off.setSpacing
(Integer spacing) Sets horizontal space between legend items, in pixels.setSwitchable
(Boolean switchable) Set switchable to true if graphs should be shown/hidden by clicking on the legend marker.setSwitchColor
(Color switchColor) Sets legend switch color.setSwitchType
(LegendSwitch switchType) Sets legend switch type (in case the legend is switchable).setTabIndex
(Integer tabIndex) Sets tab index to the legend.setTextClickEnabled
(Boolean textClickEnabled) Set textClickEnabled to true if you want show/hide balloon of the graph by click on the text.Sets distance from top of the chart, in pixels, if legend position is set to "absolute".setUseGraphSettings
(Boolean useGraphSettings) Set useGraphSettings to true if you want to use graph’s settings.setUseMarkerColorForLabels
(Boolean useMarkerColorForLabels) Set useMarkerColorForLabels to true if you wantlabels
should use marker color.setUseMarkerColorForValues
(Boolean useMarkerColorForValues) Set useMarkerColorForValues to true if legend values should use the same color as corresponding markers.setValueAlign
(ValueAlign valueAlign) Sets alignment of the value text.setValueFunction
(JsFunction valueFunction) Sets JS function to format value labels.setValueText
(String valueText) Sets the text which will be displayed in the value portion of the legend.setValueWidth
(Integer valueWidth) Sets width of the value text.setVerticalGap
(Integer verticalGap) Sets vertical space between legend items also between legend border and first and last legend row.Sets width of a legend, when position is set to absolute.
-
Constructor Details
-
AbstractLegend
public AbstractLegend()
-
-
Method Details
-
getAlign
- Returns:
- alignment of legend entries
-
setAlign
Sets alignment of legend entries. Possible values are: "left", "center", "right". If not set the default value is LEFT.- Parameters:
align
- align- Returns:
- legend
-
getAutoMargins
- Returns:
- true if margins of the legend is adjusted and made equal to chart's margins
-
setAutoMargins
Set autoMargins to true if you want margins of the legend should be adjusted and made equal to chart's margins. Used if chart is Serial or XY. If not set the default value is true.- Parameters:
autoMargins
- autoMargins option- Returns:
- legend
-
getBackgroundAlpha
- Returns:
- opacity of legend's background
-
setBackgroundAlpha
@StudioProperty(defaultValue="0") @Max(1L) @Min(0L) public T setBackgroundAlpha(Double backgroundAlpha) Sets opacity of legend's background. Value range is 0 - 1. If not set the default value is 0.- Parameters:
backgroundAlpha
- opacity- Returns:
- legend
-
getBackgroundColor
- Returns:
- background color
-
setBackgroundColor
@StudioProperty(type=OPTIONS, defaultValue="#FFFFFF") public T setBackgroundColor(Color backgroundColor) Sets background color. You should set backgroundAlpha to greater than 0 value in order background to be visible. If not set the default value is #FFFFFF.- Parameters:
backgroundColor
- background color- Returns:
- legend
-
getBorderAlpha
- Returns:
- opacity of chart's border
-
setBorderAlpha
Sets opacity of chart's border. Value range is 0 - 1. If not set the default value is 0.- Parameters:
borderAlpha
- opacity- Returns:
- legend
-
getBorderColor
- Returns:
- color of legend's border
-
setBorderColor
Sets color of legend's border. You should set borderAlpha to greater than 0 in order border to be visible. If not set the default value is #000000.- Parameters:
borderColor
- border color- Returns:
- legend
-
getBottom
- Returns:
- distance from bottom of the chart, in pixels
-
setBottom
Sets distance from bottom of the chart, in pixels if legend position is set to "absolute".- Parameters:
bottom
- bottom- Returns:
- legend
-
getColor
- Returns:
- text color
-
setColor
Sets text color. If not set the default value is #000000.- Parameters:
color
- text color- Returns:
- legend
-
getData
- Returns:
- list of legend items
-
setData
Sets list of legend items.- Parameters:
data
- list of legend items- Returns:
- legend
-
addItems
Adds items.- Parameters:
items
- items- Returns:
- legend
-
getEqualWidths
- Returns:
- true if each of legend entry is equal to the most wide entry
-
setEqualWidths
Set equalWidths to false if each of legend entry shouldn't be equal to the most widest entry. Won't look good if legend has more than one line. If not set the default value is true.- Parameters:
equalWidths
- equals widths option- Returns:
- legend
-
getFontSize
- Returns:
- font size.
-
setFontSize
Sets font size. If not set the default value is 11.- Parameters:
fontSize
- font size- Returns:
- legend
-
getHorizontalGap
- Returns:
- horizontal space between legend item and left/right border
-
setHorizontalGap
Sets horizontal space between legend item and left/right border. If not set the default value is 0.- Parameters:
horizontalGap
- horizontal gap- Returns:
- legend
-
getLabelText
- Returns:
- the text which will be displayed in the legend
-
setLabelText
Sets the text which will be displayed in the legend. Tag [[title]] will be replaced with the title of the graph. If not set the default value is "[[title]]".- Parameters:
labelText
- label text- Returns:
- legend
-
getLeft
- Returns:
- distance from left side of the chart, in pixels
-
setLeft
Sets distance from left side of the chart, in pixels. In case legend position is set to "absolute".- Parameters:
left
- distance from left side of the chart, in pixels- Returns:
- legend
-
getMarginBottom
- Specified by:
getMarginBottom
in interfaceHasMargins<T extends AbstractLegend>
- Returns:
- bottom spacing
-
setMarginBottom
Description copied from interface:HasMargins
Sets bottom spacing. If not set the default value is 10.If is used for
Legend
default value is 0.If is used for
RadarChartModelImpl
the default value is 0.If is used for chart based on
RectangularChartModelImpl
(GanttChart, SerialChart, XYChart) the default value is 20.If is used for chart based on
SlicedChartModelImpl
(FunnelChart, PieChart) the default value is 10.If is used for
PanelsSettings
the default value is 0.- Specified by:
setMarginBottom
in interfaceHasMargins<T extends AbstractLegend>
- Parameters:
marginBottom
- bottom spacing- Returns:
- object with set bottom spacing
-
getMarginLeft
- Specified by:
getMarginLeft
in interfaceHasMargins<T extends AbstractLegend>
- Returns:
- left-hand spacing
-
setMarginLeft
Description copied from interface:HasMargins
Sets left-hand spacing.marginLeft will be ignored if chart is
SerialChart
orXYChartModelImpl
andautoMargins
is true.If is used for
Legend
the default value is 20.If is used for
RadarChartModelImpl
the default value is 0.If is used for chart based on
RectangularChartModelImpl
(GanttChart, SerialChart, XYChart) the default value is 20.If is used for chart based on
SlicedChartModelImpl
the default value is 0.If is used for
PanelsSettings
the default value is 0.- Specified by:
setMarginLeft
in interfaceHasMargins<T extends AbstractLegend>
- Parameters:
marginLeft
- left-hand spacing- Returns:
- object with set left-hand spacing
-
getMarginRight
- Specified by:
getMarginRight
in interfaceHasMargins<T extends AbstractLegend>
- Returns:
- right-hand spacing
-
setMarginRight
Description copied from interface:HasMargins
Sets right-hand spacing.marginRight will be ignored if chart is
SerialChart
orXYChartModelImpl
andautoMargins
is true.If is used for
Legend
the default value is 20.If is used for
RadarChartModelImpl
the default value is 0.If is used for chart based on
RectangularChartModelImpl
(GanttChart, SerialChart, XYChart) the default value is 20.If is used for chart based on
SlicedChartModelImpl
(FunnelChart, PieChart) the default value is 0.If is used for
PanelsSettings
the default value is 0.- Specified by:
setMarginRight
in interfaceHasMargins<T extends AbstractLegend>
- Parameters:
marginRight
- right-hand spacing- Returns:
- object with set right-hand spacing
-
getMarginTop
- Specified by:
getMarginTop
in interfaceHasMargins<T extends AbstractLegend>
- Returns:
- top spacing
-
setMarginTop
Description copied from interface:HasMargins
Sets top spacing. If not set the default value is 10.If is used for
Legend
the default value is 0.If is used for
RadarChartModelImpl
the default value is 0.If is used for chart based on
RectangularChartModelImpl
(GanttChart, SerialChart, XYChart) the default value is 20.If is used for chart based on
SlicedChartModelImpl
the default value is 10.If is used for
PanelsSettings
the default value is 0.- Specified by:
setMarginTop
in interfaceHasMargins<T extends AbstractLegend>
- Parameters:
marginTop
- top spacing- Returns:
- object with set top spacing
-
getMarkerBorderAlpha
- Returns:
- marker border opacity
-
setMarkerBorderAlpha
@StudioProperty(defaultValue="1") @Max(1L) @Min(0L) public T setMarkerBorderAlpha(Double markerBorderAlpha) Sets marker border opacity. If not set the default value is 1.- Parameters:
markerBorderAlpha
- marker border opacity- Returns:
- legend
-
getMarkerBorderColor
- Returns:
- marker border color
-
setMarkerBorderColor
Sets marker border color. If not set, will use the same color as marker.- Parameters:
markerBorderColor
- marker border color- Returns:
- legend
-
getMarkerBorderThickness
- Returns:
- thickness of the legend border
-
setMarkerBorderThickness
Sets thickness of the legend border. The value 0 means the line will be a "hairline" (1 px). In case marker type is line, this style will be used for line thickness. If not set the default value is 1.- Parameters:
markerBorderThickness
- marker border thickness- Returns:
- legend
-
getMarkerDisabledColor
- Returns:
- color of the disabled marker (when the graph is hidden)
-
setMarkerDisabledColor
@StudioProperty(type=OPTIONS, defaultValue="#AAB3B3") public T setMarkerDisabledColor(Color markerDisabledColor) Sets the color of the disabled marker (when the graph is hidden). If not set the default value is #AAB3B3.- Parameters:
markerDisabledColor
- marker disabled color- Returns:
- legend
-
getMarkerLabelGap
- Returns:
- space between legend marker and legend text, in pixels
-
setMarkerLabelGap
Sets space between legend marker and legend text, in pixels. If not set the default value is 5.- Parameters:
markerLabelGap
- marker label gap- Returns:
- legend
-
getMarkerSize
- Returns:
- size of the legend marker
-
setMarkerSize
Sets size of the legend marker (key). If not set the default value is 16.- Parameters:
markerSize
- marker size- Returns:
- legend
-
getMarkerType
- Returns:
- shape of the legend marker (key)
-
setMarkerType
@StudioProperty(type=ENUMERATION, defaultValue="SQUARE") public T setMarkerType(MarkerType markerType) Sets shape of the legend marker (key). Possible values are: square, circle, diamond, triangleUp, triangleDown, triangleLeft, triangleDown, bubble, line, none. If not set the default value is SQUARE.- Parameters:
markerType
- marker type- Returns:
- legend
-
getMaxColumns
- Returns:
- maximum number of columns in the legend
-
setMaxColumns
Sets maximum number of columns in the legend. If Legend's position is set to "right" or "left", maxColumns is automatically set to 1.- Parameters:
maxColumns
- maximum number of columns- Returns:
- legend
-
getPeriodValueText
- Returns:
- text which will be displayed in the value portion of the legend when user is not hovering above any data point
-
setPeriodValueText
Sets the text which will be displayed in the value portion of the legend when user is not hovering above any data point. The tags should be made out of two parts - the name of a field (value / open / close / high / low) and the value of the period you want to be show - open / close / high / low / sum / average / count. For example: [[value.sum]] means that sum of all data points of value field in the selected period will be displayed.- Parameters:
periodValueText
- period value text- Returns:
- legend
-
getPosition
- Returns:
- position of a legend
-
setPosition
@StudioProperty(type=ENUMERATION, defaultValue="BOTTOM") public T setPosition(LegendPosition position) Sets position of a legend. Possible values are: "bottom", "top", "left", "right" and "absolute". In case "absolute", you should set left and top properties too. If not set the default value is BOTTOM.- Parameters:
position
- position- Returns:
- legend
-
getReversedOrder
- Returns:
- true if legend entries placed in reverse order
-
setReversedOrder
Set reversedOrder to true if legend entries should be placed in reversed order. If not set the default value is false.- Parameters:
reversedOrder
- reversed order option- Returns:
- legend
-
getRight
- Returns:
- distance from right side of the chart, in pixels
-
setRight
Sets distance from right side of the chart, in pixels if legend position is set to "absolute".- Parameters:
right
- distance from right side of the chart, in pixels- Returns:
- legend
-
getRollOverColor
- Returns:
- legend item text color on roll-over
-
setRollOverColor
@StudioProperty(type=OPTIONS, defaultValue="#CC0000") public T setRollOverColor(Color rollOverColor) Sets legend item text color on roll-over. If not set the default value is #CC0000.- Parameters:
rollOverColor
- roll over color- Returns:
- legend
-
getRollOverGraphAlpha
- Returns:
- opacity of the non-hovered graphs
-
setRollOverGraphAlpha
@StudioProperty(defaultValue="1") @Max(1L) @Min(0L) public T setRollOverGraphAlpha(Double rollOverGraphAlpha) Sets the opacity of the non-hovered graphs. When you roll-over the legend entry, all other graphs can reduce their opacity, so that the graph you rolled-over would be distinguished. If not set the default value is 1.- Parameters:
rollOverGraphAlpha
- roll over graph alpha- Returns:
- legend
-
getShowEntries
- Returns:
- true if all the legend entries are shown
-
setShowEntries
Set showEntries to false if you want to turn all the legend entries off. If not set the default value is true.- Parameters:
showEntries
- showEntries option- Returns:
- legend
-
getSpacing
- Returns:
- horizontal space between legend items, in pixels
-
setSpacing
Sets horizontal space between legend items, in pixels. If not set the default value is 10.- Parameters:
spacing
- horizontal space between legend items, in pixels- Returns:
- legend
-
getSwitchable
- Returns:
- true if graphs are shown/hidden by click on the legend marker
-
setSwitchable
Set switchable to true if graphs should be shown/hidden by clicking on the legend marker. If not set the default value is true.- Parameters:
switchable
- switchable option- Returns:
- legend
-
getSwitchColor
- Returns:
- legend switch color.
-
setSwitchColor
Sets legend switch color. If not set the default value is #FFFFFF- Parameters:
switchColor
- switch color- Returns:
- legend
-
getSwitchType
- Returns:
- legend switch type
-
setSwitchType
Sets legend switch type (in case the legend is switchable). Possible values are "x" and "v". If not set the default value is "x".- Parameters:
switchType
- legend switch type- Returns:
- legend
-
getTextClickEnabled
- Returns:
- true if balloon of the graph is shown/hidden by click on the text
-
setTextClickEnabled
Set textClickEnabled to true if you want show/hide balloon of the graph by click on the text. Otherwise it will show/hide graph/slice, if switchable is set to true. If not set the default value is false.- Parameters:
textClickEnabled
- textClickEnabled- Returns:
- legend
-
getTop
- Returns:
- distance from top of the chart
-
setTop
Sets distance from top of the chart, in pixels, if legend position is set to "absolute".- Parameters:
top
- distance from top of the chart, in pixels- Returns:
- legend
-
getUseGraphSettings
- Returns:
- true if graph’s settings is used
-
setUseGraphSettings
Set useGraphSettings to true if you want to use graph’s settings. Legend markers can mirror graph’s settings, displaying a line and a real bullet as in the graph itself. Note, if you set graph colors in data provider, they will not be reflected in the marker. If not set the default value is false.- Parameters:
useGraphSettings
- use graph settings option- Returns:
- legend
-
getUseMarkerColorForLabels
- Returns:
- true if
labels
use marker color
-
setUseMarkerColorForLabels
@StudioProperty(defaultValue="false") public T setUseMarkerColorForLabels(Boolean useMarkerColorForLabels) Set useMarkerColorForLabels to true if you wantlabels
should use marker color. If not set the default value is false.- Parameters:
useMarkerColorForLabels
- useMarkerColorForLabels option- Returns:
- legend
-
getUseMarkerColorForValues
- Returns:
- true if legend values use the same color as corresponding markers
-
setUseMarkerColorForValues
@StudioProperty(defaultValue="false") public T setUseMarkerColorForValues(Boolean useMarkerColorForValues) Set useMarkerColorForValues to true if legend values should use the same color as corresponding markers. If not set the default value is false.- Parameters:
useMarkerColorForValues
- useMarkerColorForValues option- Returns:
- legend
-
getValueAlign
- Returns:
- alignment of the value text
-
setValueAlign
@StudioProperty(type=ENUMERATION, defaultValue="RIGHT") public T setValueAlign(ValueAlign valueAlign) Sets alignment of the value text. Possible values are "left" and "right". If not set the default value is RIGHT.- Parameters:
valueAlign
- alignment of the value text- Returns:
- legend
-
getValueText
- Returns:
- text which is displayed in the value portion of the legend
-
setValueText
Sets the text which will be displayed in the value portion of the legend. You can use tags like [[value]], [[open]], [[high]], [[low]], [[close]], [[percents]], [[description]]. If not set the default value is "[[value]]".- Parameters:
valueText
- value text- Returns:
- legend
-
getValueWidth
- Returns:
- width of the value text
-
setValueWidth
Sets width of the value text. If not set the default value is 50.- Parameters:
valueWidth
- value width- Returns:
- legend
-
getVerticalGap
- Returns:
- vertical space between legend items also between legend border and first and last legend row
-
setVerticalGap
Sets vertical space between legend items also between legend border and first and last legend row. If not set the default value is 10.- Parameters:
verticalGap
- vertical space- Returns:
- legend
-
getDivId
- Returns:
- id of a div in which the legend is placed
-
setDivId
Sets id of a div in case you want the legend to be placed in a separate container.- Parameters:
divId
- id of a div- Returns:
- legend
-
getEnabled
- Returns:
- true if is enabled
-
setEnabled
Specifies if legend is enabled or not. If not set the default value is true.- Parameters:
enabled
- enabled option- Returns:
- legend
-
getLabelWidth
- Returns:
- label width
-
setLabelWidth
Sets label width. If width of the label is bigger than labelWidth, it will be wrapped.- Parameters:
labelWidth
- label width- Returns:
- legend
-
getValueFunction
- Returns:
- JS function to format value labels
-
setValueFunction
Sets JS function to format value labels. Legend will call this method and will pass GraphDataItem and formatted text of currently hovered item (works only withCursor
added to the chart). This method should return string which will be displayed as value in the legend.- Parameters:
valueFunction
- JS function- Returns:
- legend
-
getWidth
- Returns:
- width of a legend
-
setWidth
Sets width of a legend, when position is set to absolute.- Parameters:
width
- width of a legend- Returns:
- legend
-
getForceWidth
- Returns:
- false if the width of legend item labels adjusts
-
setForceWidth
Set forceWidth to true if you want the width of legend item labels won't be adjusted. Useful when you have more than one chart and want to align all the legends. If not set the default value is false.- Parameters:
forceWidth
- force width option- Returns:
- legend
-
getGradientRotation
- Returns:
- gradient rotation of the legend
-
setGradientRotation
@StudioProperty(type=ENUMERATION, options={"0","90","180","270"}) public T setGradientRotation(Integer gradientRotation) Sets gradient rotation of the legend. Can be used if legend uses custom data. Set it to 0, 90, 180 or 270.- Parameters:
gradientRotation
- gradient rotation of the legend- Returns:
- legend
-
getTabIndex
- Returns:
- tab index
-
setTabIndex
Sets tab index to the legend. Chart will set focus on legend entry when user clicks tab key. When a focus is set, screen readers like NVDA Screen reader will read label which is set using accessibleLabel property of Legend. If legend has switchable set to true, pressing Enter (Return) key will show/hide the graph. Note, not all browsers and readers support this.- Parameters:
tabIndex
- tab index- Returns:
- legend
-
getAccessibleLabel
- Returns:
- text which screen readers will read if user rolls-over the element or sets focus on it using tab key
-
setAccessibleLabel
@StudioProperty(type=LOCALIZED_STRING, defaultValue="[[title]]") public T setAccessibleLabel(String accessibleLabel) Sets the text which screen readers will read if user rolls-over the element or sets focus on it using tab key (this is possible only if tabIndex property is set to some number). Text is added as aria-label tag. Note, not all screen readers and browsers support this. If not set the default value is "[[title]]".- Parameters:
accessibleLabel
- accessible label text- Returns:
- legend
-
getCombineLegend
- Returns:
- true if displayed legend data and graph’s entries
-
setCombineLegend
Set combineLegend to true if you want to display both legend data and graph’s entries. If not set the default value is false.- Parameters:
combineLegend
- combineLegend option
-