I am working with a pie chart (FLEX 2) and I want to show Legend also. I can see the legends in the bottom of the chart but there is no label for legends. I can see only three different color boxes (without label on it). How can I show the label.
Here is the code
<?xml version="1.0"?>
<!-- Simple example to demonstrate the PieChart control. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
private var medalsAC:ArrayCollection = new ArrayCollection( [
{ Country: "USA", Gold: 35, Silver:39, Bronze: 29 },
{ Country: "China", Gold: 32, Silver:17, Bronze: 14 },
{ Country: "Russia", Gold: 27, Silver:27, Bronze: 38 } ]);
private function displayGold(data:Object, field:String, index:Number, percentValue:Number):String {
var temp:String= (" " + percentValue).substr(0,6);
return data.Country + ": " + '
' + "Total Gold: " + data.Gold + '
' + temp + "%";
}
]]>
</mx:Script>
<mx:Panel title="Olympics 2004 Medals Tally Panel" height="340" width="340">
<mx:PieChart id="chart2" height="100%" width="100%"
paddingRight="5" paddingLeft="5"
showDataTips="true" dataProvider="{medalsAC}">
<mx:series>
<mx:PieSeries labelPosition="callout" field="Gold" labelFunction="displayGold">
<mx:calloutStroke>
<mx:Stroke weight="0" color="0x888888" alpha="1.0"/>
</mx:calloutStroke>
<mx:radialStroke>
<mx:Stroke weight="0" color="#FFFFFF" alpha="0.20"/>
</mx:radialStroke>
<mx:stroke>
<mx:Stroke color="0" alpha="0.20" weight="2"/>
</mx:stroke>
</mx:PieSeries>
</mx:series>
</mx:PieChart>
<mx:Legend dataProvider="{chart2}" autoLayout="true" width="100%"
height="100%" labelPlacement="right" markerWidth="10"/>
</mx:Panel>
</mx:Application>