Important version information!

You are browsing a class reference for deprecated Version 2 of the JavaScript Charts.

Documentation for other versions: amCharts 4 (current) or amCharts 3.

StockLegend

Inheritance: StockLegendAmLegend

StockLegend is a legend of StockPanel.

Properties Hide inherited

PropertyTypeDefaultDescription
alignStringleftAlignment of legend entries. Possible values are: "left", "center", "right".
autoMarginsBooleantrueUsed if chart is Serial or XY. In case true, margins of the legend are adjusted and made equal to chart's margins.
backgroundAlphaNumber0Opacity of legend's background. Value range is 0 - 1
backgroundColorString#FFFFFFBackground color. You should set backgroundAlpha to >0 vallue in order background to be visible.
borderAlphaNumber0Opacity of chart's border. Value range is 0 - 1.
borderColorString#000000Color of legend's border. You should set borderAlpha >0 in order border to be visible.
bottomNumberIn case legend position is set to "absolute", you can set distance from bottom of the chart, in pixels.
colorHex stringText color. Will use chart's color if not set.
dataArrayThis can be used by AmMap only. You can pass array of objects with title, color, markerType values, for example: [{title: "One", color: "#3366CC"},{title: "Two", color: "#FFCC33"}]
equalWidthsBooleantrueSpecifies if each of legend entry should be equal to the most wide entry. Won't look good if legend has more than one line.
fontSizeNumberFont size. Will use chart's font size if not set.
horizontalGapNumber0Horizontal space between legend item and left/right border.
labelTextString[[title]]The text which will be displayed in the legend. Tag [[title]] will be replaced with the title of the graph.
leftNumberIn case legend position is set to "absolute", you can set distance from left side of the chart, in pixels.
marginBottomNumber0Bottom margin.
marginLeftNumber20Left margin. This property will be ignored if chart is Serial or XY and autoMargins property of the legend is true (default).
marginRightNumber20Right margin. This property will be ignored if chart is Serial or XY and autoMargins property of the legend is true (default).
marginTopNumber0Top margin.
markerBorderAlphaNumber1Marker border opacity.
markerBorderColorHex stringMarker border color. If not set, will use the same color as marker.
markerBorderThicknessNumber1Thickness of the legend border. The default 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.
markerDisabledColorHex string#AAB3B3The color of the disabled marker (when the graph is hidden).
markerLabelGapNumber5Space between legend marker and legend text, in pixels.
markerSizeNumber16Size of the legend marker (key).
markerTypeStringsquareShape of the legend marker (key). Possible values are: "square", "circle", "line", "dashedLine", "triangleUp", "triangleDown", "bubble", "none".
maxColumnsNumberMaximum number of columns in the legend. If Legend's position is set to "right" or "left", maxColumns is automatically set to 1.
positionStringbottomPosition of a legend. Possible values are: "bottom", "top", "left", "right" and "absolute". In case "absolute", you should set left and top properties too. (this setting is ignored in Stock charts). In case legend is used with AmMap, position is set to "absolute" automatically.
reversedOrderBooleanfalseSpecifies whether legend entries should be placed in reversed order.
NumberIn case legend position is set to "absolute", you can set distance from right side of the chart, in pixels.
rollOverColorString#CC0000Legend item text color on roll-over.
rollOverGraphAlphaNumber1When you roll-over the legend entry, all other graphs can reduce their opacity, so that the graph you rolled-over would be distinguished. This style specifies the opacity of the graphs.
showEntriesBooleantrueYou can use this property to turn all the legend entries off.
spacingNumber10Horizontal space between legend items, in pixels.
switchableBooleantrueWhether showing/hiding of graphs by clicking on the legend marker is enabled or not. In case legend is used with AmMap, this is set to false automatically.
switchColorHex string#FFFFFFLegend switch color.
switchTypeStringxLegend switch type (in case the legend is switchable). Possible values are "x" and "v".
textClickEnabledBooleanfalseIf true, clicking on the text will show/hide balloon of the graph. Otherwise it will show/hide graph/slice, if switchable is set to true.
topNumberIn case legend position is set to "absolute", you can set distance from top of the chart, in pixels.
useMarkerColorForLabelsBooleanfalseLabels will use marker color if you set this to true.
useMarkerColorForValuesBooleanfalseSpecifies if legend values should be use same color as corresponding markers.
valueAlignStringrightAlignment of the value text. Possible values are "left" and "right".
valueTextString[[value]]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]].
valueTextComparingString[[percents.value]]%The text which will be displayed in the value portion of the legend when graph is comparable and at least one dataSet is selected for comparing. You can use tags like [[value]], [[open]], [[high]], [[low]], [[close]], [[percents.value/open/close/low/high]], [[description]].
valueTextRegularString[[value]]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]].
valueWidthNumber80Width of the value text.
verticalGapNumber10Vertical space between legend items also between legend border and first and last legend row.

Methods Hide inherited

NameParametersReturnsDescription
addListener(type, handler)type - string like 'clickLabel' (should be listed in 'events' section of this class or classes which extend this class). handler - function which is called when event happensAdds event listener to the object.
removeListener(legend, type, handler)Removes event listener from the legend object.

Events Hide inherited

NameEvent objectDescription
clickLabel{type:"clickLabel", dataItem:Object, chart:AmChart}Dispatched when legend label is clicked.
clickMarker{type:"clickMarker", dataItem:Object, chart:AmChart}Dispatched when legend marker is clicked.
hideItem{type:"hideItem", dataItem:Object, chart:AmChart}Dispatched when user clicks on a legend item marker and hides corresponding object.
rollOutItem{type:"rollOutItem", dataItem:Object, chart:AmChart}Dispatched when user rolls-out of the legend item label (or whole item, if switchable is set to false).
rollOverItem{type:"rollOverItem", dataItem:Object, chart:AmChart}Dispatched when user rolls-over the legend item label (or whole item, if switchable is set to false).
rollOverMarker{type:"rollOverMarker", dataItem:Object, chart:AmChart}Dispatched when user rolls-over the legend item marker.
showItem{type:"showItem", dataItem:Object, chart:AmChart}Dispatched when user clicks on a legend item marker and shows corresponding object.