
ADOBE FLEX 3
Adobe Flex 3 Data Visualization Developer Guide
16
• Most of the series can determine suitable defaults for their nonprimary dimensions if no field is specified. For
example, if you do not explicitly set an
xField for the ColumnSeries, LineSeries, and AreaSeries, Flex maps the
data to the chart’s categories in the order in which the data appears in the data provider. Similarly, a BarSeries maps
the data to the categories if you do not set a
yField.
For a complete list of the fields that each data series can use, see the data series entry in Adobe Flex Language
Reference. For more information on data providers, see “Data provider controls” on page 227 in Adobe Flex 3
Developer Guide.
Sources of chart data
You can supply data to a data provider in the following ways:
• Define it in a <mx:Script> block.
• Define it in an external XML, ActionScript, or text file.
• Return it by using a We bS e r vi c e call.
• Return it by using a RemoteObject component.
• Return it by using an HTTPService component.
• Define it in MXML.
There are some limitations on the structure of the chart data, and how to reference chart data if it is constructed with
complex objects. For more information, see “Structure of chart data” on page 28.
For more information on data providers, see “Using Data Providers and Collections” on page 137 in Adobe Flex 3
Developer Guide.
Using static Arrays as data providers
Using a static Array of objects for the data provider is the simplest approach. You typically create an Array of objects,
as the following example shows:
<?xml version="1.0"?>
<!-- charts/ArrayOfObjectsDataProvider.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script><![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
private var expenses:Array = [
{Month:"January",Profit:2000,Expenses:1500,Amount:450},
{Month:"February",Profit:1000,Expenses:200,Amount:600},
{Month:"March",Profit:1500,Expenses:500,Amount:300},
{Month:"April",Profit:500,Expenses:300,Amount:500},
{Month:"May",Profit:1000,Expenses:450,Amount:250},
{Month:"June",Profit:2000,Expenses:500,Amount:700}
];
]]></mx:Script>
<mx:Panel title="Column Chart">
<mx:ColumnChart id="myChart" dataProvider="{expenses}" showDataTips="true">
<mx:horizontalAxis>
<mx:CategoryAxis
dataProvider="{expenses}"
categoryField="Month"
/>
</mx:horizontalAxis>
<mx:series>
<mx:ColumnSeries
xField="Month"