我必须展示一个包含两个系列的折线图,每个系列都有“日期值”,因为每个系列中的日期可能相距甚远,它们有自己的水平轴。
问题是当我向系列添加动画时,动画开始循环并且永不停止。
我的问题是:我做错了吗?或者这是弹性图表中的错误?
有谁知道如何解决这个问题?
这是一个示例代码:`
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.collections.ArrayCollection;
[Bindable]
private var arr1:ArrayCollection = new ArrayCollection([
{date_1:"01/2008", value_1:2, date_2:"01/2007", value_2:4},
{date_1:"02/2008", value_1:5, date_2:"02/2007", value_2:7},
{date_1:"03/2008", value_1:4, date_2:"03/2007", value_2:3},
{date_1:"04/2008", value_1:7, date_2:"04/2007", value_2:5}]);
[Bindable]
private var arr2:ArrayCollection = new ArrayCollection([
{date_1:"01/2008", value_1:4, date_2:"01/2007", value_2:7},
{date_1:"02/2008", value_1:3, date_2:"02/2007", value_2:5},
{date_1:"03/2008", value_1:5, date_2:"03/2007", value_2:2},
{date_1:"04/2008", value_1:4, date_2:"04/2007", value_2:5}]);
private var temp:Boolean = false;
private function switchGraf():void{
if( temp){
series_1.dataProvider = arr1;
series_2.dataProvider = arr1;
} else {
series_1.dataProvider = arr2;
series_2.dataProvider = arr2;
}
temp = !temp;
}
]]>
</mx:Script>
<mx:SeriesSlide direction="right" duration="1000" id="aniShow"/>
<mx:SeriesSlide direction="left" duration="1000" id="aniHide"/>
<mx:ComboBox change="switchGraf()">
<mx:String>one</mx:String>
<mx:String>two</mx:String>
</mx:ComboBox>
<mx:LineChart>
<mx:series>
<mx:LineSeries id="series_1" yField="value_1" dataProvider="{arr1}" showDataEffect="aniShow" hideDataEffect="aniHide">
<mx:horizontalAxis>
<mx:CategoryAxis id="axis_1" categoryField="date_1"/>
</mx:horizontalAxis>
</mx:LineSeries>
<mx:LineSeries id="series_2" yField="value_2" dataProvider="{arr1}">
<mx:horizontalAxis>
<mx:CategoryAxis id="axis_2" categoryField="date_2"/>
</mx:horizontalAxis>
</mx:LineSeries>
</mx:series>
<mx:verticalAxis>
<mx:LinearAxis minimum="0" maximum="10"/>
</mx:verticalAxis>
<mx:horizontalAxisRenderers>
<mx:AxisRenderer placement="bottom" axis="{axis_1}"/>
<mx:AxisRenderer placement="top" axis="{axis_2}"/>
</mx:horizontalAxisRenderers>
</mx:LineChart>
`
有任何想法吗?