Flex 4图表使用实例ColumnChart

本例子针对flash.com/article/flex' target='_blank'>flex的ColumnChart组件写的例子,通过设置ColumnChar的type为不同的类型,得出不同的列状图表。

ColumnChar的type有100%、clustered、overlaid、stacked四种。四种例子都是用到的代码:

<?xml version="1.0" encoding="utf-8"?>
< s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flash.com/article/flex' target='_blank'>flex/spark"
xmlns:mx="library://ns.adobe.com/flash.com/article/flex' target='_blank'>flex/mx" minWidth="955" minHeight="600">
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;

[Bindable]
private var money:ArrayCollection = new ArrayCollection( [
{ month:6, Fare:120, CostOfLiving:470, Play:231, other:510 },
{ month:7, Fare:120, CostOfLiving:500, Play:106, other:23},
{ month:8, Fare:120, CostOfLiving:650, Play:43, other:342},
{ month:9, Fare:120, CostOfLiving:704, Play:180, other:18},
{ month:10, Fare:120, CostOfLiving:512, Play:410, other:123},
{ month:11, Fare:120, CostOfLiving:823, Play:123, other:124},
])
]]>
</fx:Script>
<mx:ColumnChart id="column" type="stackedclustered overlaid"
dataProvider="{money}">
<mx:horizontalAxis>
<mx:CategoryAxis categoryField="month" />
</mx:horizontalAxis>
<mx:series>
<mx:ColumnSeries displayName="Fare" yField="Fare">
<mx:fill>
<mx:RadialGradient>
<mx:entries>
<mx:GradientEntry color="#f23f0" />
<mx:GradientEntry color="#f0420" ratio="0"/>
</mx:entries>
</mx:RadialGradient>
</mx:fill>
</mx:ColumnSeries>
<mx:ColumnSeries displayName="CostOfLiving" yField="CostOfLiving">
<mx:fill>
<mx:SolidColor color="#0350f">
</mx:SolidColor>
</mx:fill>
</mx:ColumnSeries>
<mx:ColumnSeries displayName="Play" yField="Play">
<mx:fill>
<mx:SolidColor color="#0af00"/>
</mx:fill>
</mx:ColumnSeries>
<mx:ColumnSeries displayName="other" yField="other">
<mx:fill>
<mx:SolidColor color="#f08788"/>
</mx:fill>
</mx:ColumnSeries>
</mx:series>
</mx:ColumnChart>
<mx:Legend dataProvider="{column}" x="424" y="14"/>
< /s:Application>

(1)type="100%"时,显示如下:

(2)、type="clustered"显示如下:

(3)、type="overlaid"显示如下:

(4)、type="stacked":显示如下:

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值