如何快速学习:[1]Swift编程语言,Swift,苹果于2014年WWDC(苹果开发者大会)发布的新开发语言,可与Ojective-C*共同运行于MacOS和iOS平台,用于搭建基于苹果平台的应用程......
2023-03-17 250 编程语言
依然是分享关于图标的,这个与前连个在效果上就有些不同了,
1,这个可能要稍微复杂一点了,
2,图标色调可以自定义哦。
首先是定义一些数据,作为下面图标的数据源。这里的import是导入需要的包哦,mx.collections.ArrayCollection就是说明下文中ArrayCollection使用的是来自mx.collections包下的哦。
import mx.collections.ArrayCollection;
[Bindable]
private var medalsAC:ArrayCollection = new ArrayCollection( [
{ Country: "USA", Gold: 35, Silver:39, Bronze: 29 },
{ Country: "China", Gold: 32, Silver:17, Bronze: 14 },
{ Country: "Russia", Gold: 27, Silver:27, Bronze: 38 }
]);
这里是图标的效果样式配置,其中有颜色,透明度,还有图标中线的粗细等。在这里你可以把样式修改成你自己的,比如把下边那个yellow换成红色,只要你愿意想怎么改就怎么该,另外颜色值支持多种形式哦,在下面的代码中就有提现哦。
mx:SolidColor id="sc1" color="yellow" alpha=".8"/>
mx:SolidColor id="sc2" color="0xCCCCCC" alpha=".6"/>
mx:SolidColor id="sc3" color="0xFFCC66" alpha=".6"/>
mx:Stroke id="s1" color="yellow" weight="2"/>
mx:Stroke id="s2" color="0xCCCCCC" weight="2"/>
mx:Stroke id="s3" color="0xFFCC66" weight="2"/>
这是主要就是图表的显示与布局配置。这这里你可以改变图表在哪显示,显示多大,怎么显示,就行下面的layout值是horizontal,说明要求panel内的元元素水平显示,当让showDataTips设置为true的时候,是指定该元素在鼠标停在上面的时候可以显示一些信息。
mx:Panel title="ColumnChart and BarChart Controls Example"
height="100%" width="100%" layout="horizontal">
mx:ColumnChart id="column"
height="100%" width="45%"
paddingLeft="5" paddingRight="5"
showDataTips="true" dataProvider="{medalsAC}" >
mx:horizontalAxis>
mx:CategoryAxis categoryField="Country"/>
/mx:horizontalAxis>
mx:series>
mx:ColumnSeries xField="Country"
yField="Gold" displayName="Gold" fill="{sc1}" stroke="{s1}"/>
mx:ColumnSeries xField="Country" yField="Silver" displayName="Silver"
fill="{sc2}" stroke="{s2}"/>
mx:ColumnSeries xField="Country"
yField="Bronze" displayName="Bronze" fill="{sc3}" stroke="{s3}"/>
/mx:series>
/mx:ColumnChart>
mx:Legend dataProvider="{column}"/>
mx:BarChart id="bar" height="100%" width="45%"
paddingLeft="5" paddingRight="5"
showDataTips="true" dataProvider="{medalsAC}">
mx:verticalAxis>
mx:CategoryAxis categoryField="Country"/>
/mx:verticalAxis>
mx:series>
mx:BarSeries yField="Country" xField="Gold" displayName="Gold"
fill="{sc1}" stroke="{s1}"/>
mx:BarSeries
yField="Country" xField="Silver" displayName="Silver"
fill="{sc2}" stroke="{s2}"/>
mx:BarSeries
yField="Country" xField="Bronze"
displayName="Bronze" fill="{sc3}" stroke="{s3}"/>
/mx:series>
/mx:BarChart>
mx:Legend dataProvider="{bar}"/>
/mx:Panel>
当以上步骤都完成以后就可以编译查看效果了哦。把鼠标停留在柱面上看看效果。这个的颜色就不太好看了,你可以通过修改第二步中的配置来更改图表的整体风格哦,当然背景什么的你可以直接去设置css来改变。
以上方法由办公区教程网编辑摘抄自百度经验可供大家参考!
标签: 编程语言
相关文章
如何快速学习:[1]Swift编程语言,Swift,苹果于2014年WWDC(苹果开发者大会)发布的新开发语言,可与Ojective-C*共同运行于MacOS和iOS平台,用于搭建基于苹果平台的应用程......
2023-03-17 250 编程语言
web图表开发工具FineReport:[11]连续分组,数据库表数据是按照时间先后录入的,查询的时候希望按照时间先后,某个字段连续相同的话就合并起来显示,这样的报表可以通过相邻连续分组来实现。......
2023-03-17 482 编程语言