| Package | com.amcharts |
| Class | public class AmLegend |
| Inheritance | AmLegend mx.core.UIComponent |
| Property | Defined by | ||
|---|---|---|---|
| adjustWidth : Boolean
If adjustWidth is true, the legend will srink so that it would take only space needed for all the entries.
| AmLegend | ||
| dataProvider : AmChart
[write-only]
Data provider of the legend is the chart object.
| AmLegend | ||
| labelText : String
The text which will be displayed in the legend.
| AmLegend | ||
| numberFormatter : NumberFormatter
An instance of mx.formatters.NumberFormatter.
| AmLegend | ||
| percentFormatter : NumberFormatter
An instance of mx.formatters.NumberFormatter.
| AmLegend | ||
| textClickEnabled : Boolean
Specifies whether the legend text is clickable or not.
| AmLegend | ||
| useMarkerColorForLabels : Boolean
Specifies if legend labels should be use same color as corresponding markers.
| AmLegend | ||
| usePositiveNegativeOnPercentsOnly : Boolean
If positiveValueColor and negativeValueColor styles are defined, legend value changes it's color depending on the value.
| AmLegend | ||
| valueFunction : Function
You can set custom function which will format your value text using this property
| AmLegend | ||
| valueText : String
The text which will be displayed in the value portion of the legend.
| AmLegend | ||
| Method | Defined by | ||
|---|---|---|---|
|
AmLegend()
Constructor.
| AmLegend | ||
|
setActualSize(w:Number, h:Number):void
| AmLegend | ||
| Event | Summary | Defined by | ||
|---|---|---|---|---|
| Dispatched when user clicks on a legend item label. | AmLegend | |||
| Dispatched when user clicks on a legend item marker (and the switchable is set to "false"). | AmLegend | |||
| Dispatched when user clicks on a legend item marker and hides corresponding object. | AmLegend | |||
| Dispatched when user rolls-out of the legend item label (or whole item, if switchable is set to false). | AmLegend | |||
| Dispatched when user rolls-out of the legend item marker. | AmLegend | |||
| Dispatched when user rolls-over the legend item label (or whole item, if switchable is set to false). | AmLegend | |||
| Dispatched when user rolls-over the legend item marker. | AmLegend | |||
| Dispatched when user clicks on a legend item marker and shows corresponding object. | AmLegend | |||
| adjustWidth | property |
adjustWidth:Boolean [read-write]If adjustWidth is true, the legend will srink so that it would take only space needed for all the entries. useful with horizontal layout and when maxColumns is set.
The default value is false.
public function get adjustWidth():Boolean
public function set adjustWidth(value:Boolean):void
| dataProvider | property |
dataProvider:AmChart [write-only]Data provider of the legend is the chart object.
Implementation public function set dataProvider(value:AmChart):void
| labelText | property |
labelText:String [read-write]The text which will be displayed in the legend. Tag [[title]] will be replaced with the title of the graph.
The default value is [[title]].
public function get labelText():String
public function set labelText(value:String):void
| numberFormatter | property |
numberFormatter:NumberFormatter [read-write]An instance of mx.formatters.NumberFormatter. The control use this class to format the numbers.
The default value is mx.formatters.NumberFormatter.
public function get numberFormatter():NumberFormatter
public function set numberFormatter(value:NumberFormatter):void
| percentFormatter | property |
percentFormatter:NumberFormatter [read-write]An instance of mx.formatters.NumberFormatter. The control use this class to format the percent numbers.
The default value is mx.formatters.NumberFormatter with precision = 1.
public function get percentFormatter():NumberFormatter
public function set percentFormatter(value:NumberFormatter):void
| textClickEnabled | property |
textClickEnabled:Boolean [read-write]Specifies whether the legend text is clickable or not. Clicking on legend text can show/hide value balloons or pull-out/pull-in slices of pie chart.
The default value is true.
public function get textClickEnabled():Boolean
public function set textClickEnabled(value:Boolean):void
| useMarkerColorForLabels | property |
useMarkerColorForLabels:Boolean [read-write]Specifies if legend labels should be use same color as corresponding markers.
The default value is false.
public function get useMarkerColorForLabels():Boolean
public function set useMarkerColorForLabels(value:Boolean):void
| usePositiveNegativeOnPercentsOnly | property |
usePositiveNegativeOnPercentsOnly:Boolean [read-write]If positiveValueColor and negativeValueColor styles are defined, legend value changes it's color depending on the value. However sometimes users might want to use this feature only when graph's values are recalculated to percents. Set this to true in this case.
The default value is false.
public function get usePositiveNegativeOnPercentsOnly():Boolean
public function set usePositiveNegativeOnPercentsOnly(value:Boolean):void
| valueFunction | property |
valueFunction:Function [read-write]You can set custom function which will format your value text using this property
The default value is undefined.
public function get valueFunction():Function
public function set valueFunction(value:Function):void
| valueText | property |
valueText:String [read-write]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]].
The default value is [[value]].
public function get valueText():String
public function set valueText(value:String):void
| AmLegend | () | constructor |
public function AmLegend()Constructor.
| setActualSize | () | method |
public override function setActualSize(w:Number, h:Number):voidParameters
w:Number |
|
h:Number |
| clickLabel | event |
com.amcharts.events.LegendEvent
Dispatched when user clicks on a legend item label.
| clickMarker | event |
com.amcharts.events.LegendEvent
Dispatched when user clicks on a legend item marker (and the switchable is set to "false").
| hideItem | event |
com.amcharts.events.LegendEvent
Dispatched when user clicks on a legend item marker and hides corresponding object.
| rollOutItem | event |
com.amcharts.events.LegendEvent
Dispatched when user rolls-out of the legend item label (or whole item, if switchable is set to false).
| rollOutMarker | event |
com.amcharts.events.LegendEvent
Dispatched when user rolls-out of the legend item marker.
| rollOverItem | event |
com.amcharts.events.LegendEvent
Dispatched when user rolls-over the legend item label (or whole item, if switchable is set to false).
| rollOverMarker | event |
com.amcharts.events.LegendEvent
Dispatched when user rolls-over the legend item marker.
| showItem | event |
com.amcharts.events.LegendEvent
Dispatched when user clicks on a legend item marker and shows corresponding object.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:amcharts="http://www.amcharts.com/com_internal"
layout="absolute"
backgroundColor="#FFFFFF"
width="100%"
height="100%" viewSourceURL="srcview/index.html">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
private var chartData:ArrayCollection = new ArrayCollection([
{year:2005,income:23.5,expenses:18.1},
{year:2006,income:26.2,expenses:22.8},
{year:2007,income:30.1,expenses:23.9},
{year:2008,income:29.5,expenses:25.1},
{year:2009,income:24.6,expenses:25.0}
]);
]]>
</mx:Script>
<mx:VBox width="100%" height="100%">
<amcharts:AmSerialChart
width="100%"
height="100%"
id="chart"
dataProvider="{chartData}"
categoryField="year"
startDuration="1"
angle="30"
depth3D="30">
<amcharts:categoryAxis>
<amcharts:CategoryAxis gridPosition="start"/>
</amcharts:categoryAxis>
<amcharts:graphs>
<amcharts:AmGraph title="Income" id="g0" valueField="income" type="column" lineAlpha="0" fillAlphas="[1]"/>
<amcharts:AmGraph title="Expenses" id="g1" valueField="expenses" type="line" lineThickness="2" bullet="round"/>
</amcharts:graphs>
</amcharts:AmSerialChart>
<!-- You can position the Legend anywhere you want. Use Flex layout components to do this.
For example, if you'd like to have your legend on the left or on the right, you should use HBox instead of VBox -->
<amcharts:AmLegend dataProvider="{chart}" width="100%" switchType="v" marginLeft="35" textClickEnabled="false" marginBottom="15"/>
</mx:VBox>
</mx:Application>
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:amcharts="http://www.amcharts.com/com_internal"
layout="absolute"
backgroundColor="#FFFFFF"
width="100%"
height="100%" viewSourceURL="srcview/index.html">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
private var chartData:ArrayCollection = new ArrayCollection([
{year:"2000",a:20,b:5,c:10,d:5},
{year:"2001",a:21,b:6,c:10,d:10},
{year:"2002",a:24,b:7,c:9,d:10},
{year:"2003",a:21,b:5,c:10,d:8},
{year:"2004",a:24,b:4,c:10,d:8},
{year:"2005",a:26,b:8,c:10,d:9},
{year:"2006",a:27,b:9,c:12,d:9},
{year:"2007",a:29,b:9,c:13,d:8},
{year:"2008",a:30,b:10,c:14,d:7},
{year:"2009",a:26,b:12,c:15,d:8},
{year:"2010",a:24,b:11,c:13,d:9},
{year:"2011",a:22,b:14,c:11,d:8},
{year:"2012",a:21,b:16,c:11,d:7},
{year:"2013",a:20,b:17,c:13,d:6},
{year:"2014",a:15,b:19,c:13,d:5},
{year:"2015",a:14,b:18,c:14,d:3}
]);
]]>
</mx:Script>
<mx:HBox backgroundColor="#FFFFFF" width="100%" height="100%">
<mx:VBox width="50%" height="100%">
<!-- first chart -->
<amcharts:AmSerialChart
width="100%"
height="100%"
id="chart"
dataProvider="{chartData}"
categoryField="year"
plotAreaFillAlphas="[0]">
<amcharts:graphs>
<amcharts:AmGraph
color="#FFFFFF"
title="Sample a"
valueField="a"
type="line"
lineThickness="2"
lineAlpha="1"
fillAlphas="[0.7]"
showBalloon="false"/>
<amcharts:AmGraph
color="#FFFFFF"
title="Sample b"
valueField="b"
type="line"
lineThickness="2"
lineAlpha="1"
fillAlphas="[0.7]"/>
<amcharts:AmGraph
color="#FFFFFF"
title="Sample c"
valueField="c"
type="line"
lineThickness="2"
lineAlpha="1"
fillAlphas="[0.7]"
showBalloon="false"/>
<amcharts:AmGraph
color="#FFFFFF"
title="Sample d"
valueField="d"
type="line"
lineThickness="2"
lineAlpha="1"
fillAlphas="[0.7]"/>
</amcharts:graphs>
<amcharts:valueAxes>
<amcharts:ValueAxis stackType="regular" gridAlpha="0.1"/>
</amcharts:valueAxes>
<amcharts:categoryAxis>
<amcharts:CategoryAxis gridAlpha="0.1" fontWeight="bold" startOnAxis="true" position="top"/>
</amcharts:categoryAxis>
<amcharts:chartScrollbar>
<amcharts:ChartScrollbar height="20"/>
</amcharts:chartScrollbar>
<amcharts:chartCursor>
<amcharts:ChartCursor/>
</amcharts:chartCursor>
</amcharts:AmSerialChart>
<amcharts:AmLegend
fontWeight="bold"
reversedOrder="true"
rollOverGraphAlpha="0.1"
dataProvider="{chart}"
width="100%"
marginLeft="35"
marginRight="15"
markerType="circle"
switchType="v"/>
</mx:VBox>
<mx:VBox width="50%" height="100%">
<!-- Second chart - almost the same, only rotated -->
<amcharts:AmSerialChart
rotate="true"
width="100%"
height="100%"
id="chart2"
dataProvider="{chartData}"
categoryField="year"
plotAreaFillAlphas="[0]">
<amcharts:graphs>
<amcharts:AmGraph
color="#FFFFFF"
title="Sample a"
valueField="a"
type="step"
lineThickness="2"
lineAlpha="1"
fillAlphas="[0.7]"
balloonText="[[percents]]%"/>
<amcharts:AmGraph
color="#FFFFFF"
title="Sample b"
valueField="b"
type="step"
lineThickness="2"
lineAlpha="1"
fillAlphas="[0.7]"
showBalloon="false"
balloonText="[[percents]]%"/>
<amcharts:AmGraph
color="#FFFFFF"
title="Sample c"
valueField="c"
type="step"
lineThickness="2"
lineAlpha="1"
fillAlphas="[0.7]"
showBalloon="false"
balloonText="[[percents]]%"/>
<amcharts:AmGraph
color="#FFFFFF"
title="Sample d"
valueField="d"
type="step"
lineThickness="2"
lineAlpha="1"
fillAlphas="[0.7]"
balloonText="[[percents]]%"/>
</amcharts:graphs>
<amcharts:valueAxes>
<amcharts:ValueAxis stackType="100%" gridAlpha="0.1"/>
</amcharts:valueAxes>
<amcharts:categoryAxis>
<amcharts:CategoryAxis gridAlpha="0.1" fontWeight="bold" startOnAxis="true" position="left"/>
</amcharts:categoryAxis>
<amcharts:chartScrollbar>
<amcharts:ChartScrollbar height="20"/>
</amcharts:chartScrollbar>
<amcharts:chartCursor>
<amcharts:ChartCursor/>
</amcharts:chartCursor>
</amcharts:AmSerialChart>
<amcharts:AmLegend
markerType="square"
fontWeight="bold"
reversedOrder="true"
rollOverGraphAlpha="0.1"
dataProvider="{chart2}"
width="100%"
marginLeft="52"
marginRight="15"
switchType="x"
valueText="[[percents]]%"
valueAlign="right"/>
</mx:VBox>
</mx:HBox>
</mx:Application>