站长网 Unix Flex中通过RadioButton进行切换示例代码

Flex中通过RadioButton进行切换示例代码

?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” width=”100%” s:layout s:BasicLayout/ /s:layout fx:Declarati


<?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”
width=”100%”>
<s:layout>
<s:BasicLayout/>
</s:layout>
<fx:Declarations>
<!– 将非可视元素(例如服务、值对象)放在此处 –>
</fx:Declarations>

<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;

/**
* 图的数据源绑定
*/
[Bindable]
private var chartArray:ArrayCollection = new ArrayCollection([
{week:”星期一”,apple:”451245″,orange:”894544″,peach:”451245″},
{week:”星期二”,apple:”985444″,orange:”745445″,peach:”989565″},
{week:”星期三”,apple:”124544″,orange:”323565″,peach:”323121″},
{week:”星期四”,apple:”895645″,orange:”201212″,peach:”542121″},
{week:”星期五”,apple:”325645″,orange:”564545″,peach:”656454″},
{week:”星期六”,apple:”564512″,orange:”784545″,peach:”845455″},
{week:”星期日”,apple:”784545″,orange:”656232″,peach:”124545″}
]);

/**
* RadioButton 点击事件
*/
protected function clickHandler(event:Event):void
{
if(radio_column.enabled)
{
column.height = 450;
line.height = 0;
}
else if(radio_line.enabled)
{
column.height = 0;
line.height = 450;
}
}

]]>
</fx:Script>

<mx:VBox>
<mx:VBox paddingLeft=”10″ paddingRight=”10″
paddingTop=”10″>
<mx:ColumnChart showDataTips=”true” dataProvider=”{chartArray}”>
<mx:horizontalAxis>
<mx:CategoryAxis categoryField=”week” displayName=”星期”/>
</mx:horizontalAxis>
<mx:series>
<mx:ColumnSeries displayName=”苹果” xField=”week” yField=”apple”/>
<mx:ColumnSeries displayName=”橘子” xField=”week” yField=”orange”/>
<mx:ColumnSeries displayName=”桃子” xField=”week” yField=”peach”/>
</mx:series>
</mx:ColumnChart>
<mx:Legend dataProvider=”{column}”/>
</mx:VBox>
<mx:VBox paddingLeft=”10″ paddingRight=”10″
paddingTop=”10″>
<mx:LineChart showDataTips=”true” dataProvider=”{chartArray}”>
<mx:horizontalAxis>
<mx:CategoryAxis categoryField=”week” displayName=”星期”/>
</mx:horizontalAxis>
<mx:series>
<mx:LineSeries displayName=”苹果” xField=”week” yField=”apple”/>
<mx:LineSeries displayName=”橘子” xField=”week” yField=”orange”/>
<mx:LineSeries displayName=”桃子” xField=”week” yField=”peach”/>
</mx:series>
</mx:LineChart>
<mx:Legend dataProvider=”{line}”/>
</mx:VBox>
<mx:HBox>
<mx:RadioButton label=”柱形图”/>
<mx:RadioButton label=”折线图” change=”clickHandler(event)”/>
</mx:HBox>
</mx:VBox>
</s:Application>


2、页面结果

Flex中通过RadioButton进行切换示例代码

本文来自网络,不代表站长网立场,转载请注明出处:https://www.zwzz.com.cn/html/server/unix/2021/0524/5887.html

作者: dawei

【声明】:站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。
联系我们

联系我们

0577-28828765

在线咨询: QQ交谈

邮箱: xwei067@foxmail.com

工作时间:周一至周五,9:00-17:30,节假日休息

返回顶部