| Flex 2 Developer's Guide > Charting Components > Chart Types > Using bubble charts | |||
You use the BubbleChart control to represent data with three values for each data point: a value that determines its position along the x-axis, a value that determines its position along the y-axis, and a value that determines the size of the chart symbol, relative to the other data points on the chart.
The <mx:BubbleChart> tag takes an additional property, maxRadius. This property specifies the maximum radius of the largest chart element, in pixels. The data point with the largest value is assigned this radius; all other data points are assigned a smaller radius based on their value relative to the largest value. The default value is 30 pixels.
The following example shows a bubble chart:
You use the BubbleSeries chart series with the BubbleChart control to define the data for the chart. The following table describes the properties of the BubbleSeries chart series that you commonly use to define your chart:
|
Property |
Description |
|---|---|
yField
|
Specifies the field of the data provider that determines the y-axis location of each data point. This property is required. |
xField
|
Specifies the field of the data provider that determines the x-axis location of each data point. This property is required. |
radiusField
|
Specifies the field of the data provider that determines the radius of each symbol, relative to the other data points in the chart. This property is required. |
The following example draws a BubbleChart control and sets the maximum radius of bubble elements to 50:
<?xml version="1.0"?>
<!-- charts/BasicBubble.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([
{Month:"Jan", Profit:2000, Expenses:120, Amount:45},
{Month:"Feb", Profit:1000, Expenses:200, Amount:60},
{Month:"Mar", Profit:1500, Expenses:500, Amount:30}
]);
]]></mx:Script>
<mx:Panel title="Bubble Chart">
<mx:BubbleChart id="myChart"
maxRadius="50"
dataProvider="{expenses}"
showDataTips="true"
>
<mx:series>
<mx:BubbleSeries
xField="Profit"
yField="Expenses"
radiusField="Amount"
displayName="Profit"
/>
</mx:series>
</mx:BubbleChart>
<mx:Legend dataProvider="{myChart}"/>
</mx:Panel>
</mx:Application>
Flex 2.01