flex 图表使用百分比示例
<?xml version="1.0"?>
<!-- charts/PredefinedAxisStyles.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<!--[CDATA[
//导入相关包
import mx.collections.ArrayCollection;
import mx.charts.*;
import mx.charts.series.items.ColumnSeriesItem;
import mx.charts.ChartItem;
import mx.charts.chartClasses.Series;
import mx.charts.chartClasses.IAxis;
import mx.utils.ObjectUtil;
[Bindable]
public var expenses:ArrayCollection = new ArrayCollection([
{Month:"*", Profit:20, Expenses:15},
{Month:"**", Profit:10, Expenses:20},
{Month:"***", Profit:30, Expenses:40},
{Month:"****", Profit:15, Expenses:25},
{Month:"*****", Profit:40, Expenses:45}
]);
public function myLabelFormat(obj:Object,pcat:Object,ax:LinearAxis):String
{
return numForm.format(obj)+"%";
}
private function setCustomLabel(element:ChartItem, series:Series):String {
// Get a refereence to the current data element.
var data:ColumnSeriesItem = ColumnSeriesItem(element);
// Get a reference to the current series.
var currentSeries:ColumnSeries = ColumnSeries(series);
// Create a return String and format the number.
return numForm.format(data.yNumber) + "%";
}
// This method customizes the values of the axis labels.
// This signature (with 4 arguments) is for a CategoryAxis.
public function defineLabel(
cat:Object,
pcat:Object,
ax:CategoryAxis,
labelItem:Object):String
{
// Show contents of the labelItem:
for (var s:String in labelItem) {
trace(s + ":" + labelItem[s]);
}
// Return the customized categoryField value:
//return cat + "";
return '<font size="35"><font color="#ff0000">' + cat + '</font></font>';
//'<font color="#ff0000">'
相关文档:
由于本人最近忙于找工作和毕业设计,没有时间来继续这个系列, 只写了第一篇,自己也深感惭愧,这一篇介绍一下这个demo的整体架构吧,先贴下下载地址。http://download.csdn.net/source/2118707
目前服务端已完成登陆注册模块,使用Socket编程,TCP协议。等服务端完成将完整的编写一个系列的教程。~~
......
一、准备工作:
所需要的软件:
Tomcat 5: http://tomcat.apache.org/
FlexBuilder3 beta2 插件版: FB3_WWEJ_Plugin
Eclipse 3.3 : www.eclipse.org
或者
MyEclipse 6.0:http://www.myeclipseide.com/
Blazeds.war:http://flexorg.wip3.adobe.com/blazeds/3.0.x/milestone/3978/blazeds-bin-3.2.0.39 ......
*****************************************************
1-0. 安装配置工作环境
*****************************************************
1.安装jdk1.6
设置环境变量:java_home,内容为jdk安装后jdk所在目录,不是jre目录
2.安装tomcal 6.0到d:\
3.安装myeclipse 6.5
4.安装firefox及插件
安装firefox
&nbs ......
Are you running your Flex Application and continually getting the error below?
"Flex Builder cannot locate the required version of the Flash Player. You might need to install Flash Player 9 or reinstall Flex Builder. Do you want to try to run your application with the current version?"
Description ......
CategoryAxis有一个叫做labelFunction的属性,这个属性的定义:指定一个函数,用于定义为CategoryAxis的dataProvider中的各个项目生成的标签。
所以修改的原理:可以利用labelFunction得到每个Label,然后再对其进行修改。
片段代码:
<mx:horizontalAxis>
<mx:CategoryAxis id="ca"
&nbs ......