<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="application1_creationCompleteHandler(event)">
<s:layout>
<s:VerticalLayout verticalAlign="middle" horizontalAlign="center"/>
</s:layout>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.events.FlexEvent;
[Bindable]
private var dp:ArrayCollection = new ArrayCollection([
{ Country: "USA", Gold: 35, Silver:39, Bronze: 29 },
{ Country: "China", Gold: 32, Silver:17, Bronze: 14 },
{ Country: "Russia", Gold: 7, Silver:27, Bronze: 38 }
]);
private var timer:Timer = new Timer(2000);
protected function application1_creationCompleteHandler(event:FlexEvent):void
{
timer.addEventListener(TimerEvent.TIMER,timerHandler);
timer.start();
}
private function timerHandler(event:TimerEvent):void
{
for (var i:int=0; i < dp.length; i++)
{
dp[i].Gold=dp[i].Gold + int(Math.random() * 30);
}
dp.refresh();
}
]]>
</fx:Script>
<mx:PieChart id="piechart1" width="400" height="300" dataProvider="{dp}" showDataTips="true">
<mx:series>
<mx:PieSeries nameField="Country" field="Gold"/>
</mx:series>
</mx:PieChart>
<mx:Legend dataProvider="{piechart1}"/>
</s:Application>
flex4饼状图使用(官方例子)
最新推荐文章于 2014-08-23 13:53:06 发布