| Flex 2 Developer's Guide > Charting Components > Chart Types > Using pie charts | |||
You use the PieChart control to define a standard pie chart. The data for the data provider determines the size of each wedge in the pie chart relative to the other wedges.
The following example shows a pie chart:
You use the PieSeries chart series with the PieChart control to define the data for the chart. The PieSeries can create standard pie charts or doughnut charts. PieChart controls also support labels that identify data points.
The following table describes the properties of the PieChart control's PieSeries chart series that you commonly use to define your chart:
|
Property |
Description |
|---|---|
field
|
Specifies the field of the data provider that determines the data for each wedge of the pie chart. |
labelPosition
|
Specifies how to render labels for the wedges. |
nameField
|
Specifies the field of the data provider to use as the name for the wedge in DataTips and legends. |
The following example defines a PieChart control:
<?xml version="1.0"?>
<!-- charts/BasicPie.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script><![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
public var expenses:ArrayCollection = new ArrayCollection([
{Expense:"Taxes", Amount:2000},
{Expense:"Rent", Amount:1000},
{Expense:"Bills", Amount:100},
{Expense:"Car", Amount:450},
{Expense:"Gas", Amount:100},
{Expense:"Food", Amount:200}
]);
]]></mx:Script>
<mx:Panel title="Pie Chart">
<mx:PieChart id="myChart"
dataProvider="{expenses}"
showDataTips="true"
>
<mx:series>
<mx:PieSeries
field="Amount"
nameField="Expense"
labelPosition="callout"
/>
</mx:series>
</mx:PieChart>
<mx:Legend dataProvider="{myChart}"/>
</mx:Panel>
</mx:Application>
Flex 2.01