Flex Mobile 项目中未显示图例颜色?
我是 Flex 的初学者,最近开始使用 Flash Builder 4.6 进行 Flex Mobile 项目。 该项目适用于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) 时,效果会地方。效果包括“滑动打开”效果和“轻轻拉出切片”效果。然而,传奇有标签但没有颜色。
为什么会发生这种情况?解决方案是什么?
预先感谢您提供的任何帮助。
这是屏幕截图:
I am a beginner in Flex and have recently started with Flex Mobile Projects using Flash Builder 4.6.
This project is for Android.
I wanted to add effects in my Pie Chart and made the use of :
<mx:SeriesInterpolate id="interpol"
duration="1000"
elementOffset="0"
minimumElementDuration="200"
/>
The whole code is as follows :
<?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>
I have noticed that when i set the dataProvider dynamically (myPieChart.dataProvider=expenses), the effects take place. The effects include the "swipe-open" effect and the "gently pullout slice" effect. However, the Legends have a label but no color.
Why is this happening and what is the solution to this?
Thanks in advance for any help that you can provide..
Here is the screenshot :
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
删除系列插值可能会解决该问题。这对我有用。
removing series interpolation might solve the problem. That worked for me.
系列插值效果存在一些问题
如果你删除效果一切正常
所以请参考动态绘制图例的链接
http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7c3e.html
There is some issue with seriesinterpolate effect
If you remove the effect everything works fine
so kindly refer link to draw legend dynamically
http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7c3e.html