我是Flex的初学者,最近使用Flash Builder 4.6开始使用Flex Mobile Projects。 此项目适用于 Android 。
我想在饼图中添加效果并使用:
<mx:SeriesInterpolate id="interpol"
duration="1000"
elementOffset="0"
minimumElementDuration="200"
/>
整个代码如下:
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="init()"
title="Pie Chart">
<fx:Script>
<![CDATA[
import mx.charts.events.ChartItemEvent;
import mx.collections.ArrayCollection;
[Bindable]
public var expenses:ArrayCollection = new ArrayCollection([
{ Expense:"Taxes", Amount:2000 },
{ Expense:"Rent", Amount:1000 },
{ Expense:"Timepass", Amount:500 },
{ Expense:"Screwing Around", Amount:3200 },
{ Expense:"Food", Amount:200 } ]);
private function init():void
{
pieSeries1.setStyle("showDataEffect", interpol);
myPieChart.dataProvider=expenses;
}
private function setLegends():void
{
pieLegend.dataProvider=myPieChart;
}
private function pieChart_itemClick(event:ChartItemEvent):void
{
pieHighlight( event.currentTarget.id , event.hitData.chartItem.index );
}
private function pieHighlight( pieName:String, pieIndex:int ):void
{
var explodeData:Array = []; //create an empty array
explodeData[ pieIndex ] = 0.15; //Set the index of our pie piece to > 0
this[pieName].series[0].perWedgeExplodeRadius = explodeData;
myPieChart.dataProvider=expenses;
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<mx:SeriesInterpolate id="interpol"
duration="1000"
elementOffset="0"
minimumElementDuration="200"
/>
</fx:Declarations>
<mx:PieChart id="myPieChart" x="49" y="93" width="100%" height="100%" itemClick="pieChart_itemClick(event);"
selectionMode="multiple" showDataTips="true" creationComplete="setLegends();">
<mx:series>
<mx:PieSeries id="pieSeries1" field="Amount" labelPosition="callout" nameField="Expense"/>
</mx:series>
</mx:PieChart>
<mx:Legend id="pieLegend"/>
</s:View>
我注意到当我动态设置dataProvider( myPieChart.dataProvider = expenses )时,会产生效果。效果包括“滑动打开”效果和“轻轻拉出切片”效果。但是,Legends有一个标签,但没有颜色。
为什么会发生这种情况,而 是解决方案呢?
提前感谢您提供的任何帮助..
以下是截图:
答案 0 :(得分:2)
删除系列插值可能会解决问题。这对我有用。
答案 1 :(得分:1)
系列插值效果存在一些问题 如果你删除效果一切正常 所以请参考链接动态绘制图例 http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7c3e.html