<?xml version="1.0" encoding="utf-8"?>
<mx:Application name="Legend_labelPlacement_test"
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white">
<mx:Script>
<![CDATA[
import mx.events.ListEvent;
private function directionCB_change(evt:ListEvent):void {
legend.direction = directionCB.value.toString();
}
private function labelPlacementCB_change(evt:ListEvent):void {
legend.setStyle("labelPlacement", labelPlacementCB.value);
}
]]>
</mx:Script>
<mx:XMLListCollection id="dp">
<mx:source>
<mx:XMLList>
<product label="Product 1" data="3" />
<product label="Product 2" data="1" />
<product label="Product 3" data="4" />
<product label="Product 4" data="1" />
<product label="Product 5" data="5" />
<product label="Product 6" data="9" />
</mx:XMLList>
</mx:source>
</mx:XMLListCollection>
<mx:ApplicationControlBar dock="true">
<mx:Form styleName="plain">
<mx:FormItem label="direction:">
<mx:ComboBox id="directionCB"
change="directionCB_change(event);">
<mx:dataProvider>
<mx:Array>
<mx:Object label="horizontal" />
<mx:Object label="vertical" />
</mx:Array>
</mx:dataProvider>
</mx:ComboBox>
</mx:FormItem>
<mx:FormItem label="labelPlacement:">
<mx:ComboBox id="labelPlacementCB"
selectedIndex="1"
change="labelPlacementCB_change(event);">
<mx:dataProvider>
<mx:Array>
<mx:Object label="left" />
<mx:Object label="right" />
</mx:Array>
</mx:dataProvider>
</mx:ComboBox>
</mx:FormItem>
</mx:Form>
</mx:ApplicationControlBar>
<mx:Panel styleName="opaquePanel"
width="100%"
height="100%">
<mx:PieChart id="pieChart"
dataProvider="{dp}"
height="100%"
width="100%">
<mx:series>
<mx:PieSeries id="pieSeries"
field="@data"
nameField="@label"
filters="[]" />
</mx:series>
</mx:PieChart>
<mx:ControlBar width="100%">
<mx:Legend id="legend"
dataProvider="{pieChart}"
direction="horizontal"
horizontalGap="100"
width="100%" />
</mx:ControlBar>
</mx:Panel>
</mx:Application>