PieChart组件的数据源改变后的运动效果.
示例:
代码:
代码:
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/09/24/animating-data-changes-in-a-flex-pie-chart/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white"
creationComplete="initDP();">
<mx:Script>
<![CDATA[
private const MAX_ITEMS:uint = 10;
private function initDP():void {
var i:uint;
dp = [];
for (i = 0; i < MAX_ITEMS; i++) {
dp.push({data:getRandomUint(100), label:"item " + i});
}
}
private function getRandomUint(max:uint):uint {
return Math.round(Math.random() * max);
}
]]>
</mx:Script>
<mx:Array id="dp" />
<mx:ApplicationControlBar dock="true">
<mx:Button label="Change Data"
click="initDP();" />
</mx:ApplicationControlBar>
<mx:PieChart id="chart"
height="100%"
width="100%"
dataProvider="{dp}">
<mx:series>
<mx:PieSeries field="data">
<mx:showDataEffect>
<mx:SeriesInterpolate duration="1000" />
</mx:showDataEffect>
</mx:PieSeries>
</mx:series>
</mx:PieChart>
</mx:Application>
<!-- http://blog.flexexamples.com/2007/09/24/animating-data-changes-in-a-flex-pie-chart/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white"
creationComplete="initDP();">
<mx:Script>
<![CDATA[
private const MAX_ITEMS:uint = 10;
private function initDP():void {
var i:uint;
dp = [];
for (i = 0; i < MAX_ITEMS; i++) {
dp.push({data:getRandomUint(100), label:"item " + i});
}
}
private function getRandomUint(max:uint):uint {
return Math.round(Math.random() * max);
}
]]>
</mx:Script>
<mx:Array id="dp" />
<mx:ApplicationControlBar dock="true">
<mx:Button label="Change Data"
click="initDP();" />
</mx:ApplicationControlBar>
<mx:PieChart id="chart"
height="100%"
width="100%"
dataProvider="{dp}">
<mx:series>
<mx:PieSeries field="data">
<mx:showDataEffect>
<mx:SeriesInterpolate duration="1000" />
</mx:showDataEffect>
</mx:PieSeries>
</mx:series>
</mx:PieChart>
</mx:Application>