Flex中如何通过horizontalTickAligned和verticalTickAligned样式指定线图LineChart横竖方向轴心标记的例子
原文http://blog.minidx.com/2008/12/03/1669.html
接下来的例子演示了Flex中如何通过horizontalTickAligned和verticalTickAligned样式,指定线图LineChart横竖方向轴心标记。
让我们先来看一下Demo(可以右键View Source或点击这里察看源代码):
下面是完整代码(或点击这里察看):
- <?xml version="1.0"?>
- <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
- layout="vertical"
- verticalAlign="middle"
- backgroundColor="white">
- <mx:Script>
- <![CDATA[
- import mx.charts.CategoryAxis;
- import mx.charts.chartClasses.IAxis;
- private function linearAxis_labelFunc(item:Object, prevValue:Object, axis:IAxis):String {
- return currFormatter.format(item);
- }
- private function categoryAxis_labelFunc(item:Object, prevValue:Object, axis:CategoryAxis, categoryItem:Object):String {
- var datNum:Number = Date.parse(item);
- var tempDate:Date = new Date(datNum);
- return tempDate.date.toString();
- }
- ]]>
- </mx:Script>
- <mx:CurrencyFormatter id="currFormatter" precision="2" />
- <mx:XMLListCollection id="dp">
- <mx:source>
- <mx:XMLList>
- <quote date="8/1/2007" open="40.29" close="39.58" />
- <quote date="8/2/2007" open="39.4" close="39.52" />
- <quote date="8/3/2007" open="39.47" close="38.75" />
- <quote date="8/6/2007" open="38.71" close="39.38" />
- <quote date="8/7/2007" open="39.08" close="39.42" />
- <quote date="8/8/2007" open="39.61" close="40.23" />
- <quote date="8/9/2007" open="39.9" close="40.75" />
- <quote date="8/10/2007" open="41.3" close="41.06" />
- <quote date="8/13/2007" open="41" close="40.83" />
- <quote date="8/14/2007" open="41.01" close="40.41" />
- <quote date="8/15/2007" open="40.22" close="40.18" />
- <quote date="8/16/2007" open="39.83" close="39.96" />
- <quote date="8/17/2007" open="40.18" close="40.32" />
- <quote date="8/20/2007" open="40.55" close="40.74" />
- <quote date="8/21/2007" open="40.41" close="40.13" />
- <quote date="8/22/2007" open="40.4" close="40.77" />
- <quote date="8/23/2007" open="40.82" close="40.6" />
- <quote date="8/24/2007" open="40.5" close="40.41" />
- <quote date="8/27/2007" open="40.38" close="40.81" />
- </mx:XMLList>
- </mx:source>
- </mx:XMLListCollection>
- <mx:ApplicationControlBar dock="true">
- <mx:Form styleName="plain">
- <mx:FormItem label="direction:">
- <mx:ComboBox id="comboBox">
- <mx:dataProvider>
- <mx:Array>
- <mx:Object label="both" />
- <mx:Object label="horizontal" />
- <mx:Object label="vertical" />
- </mx:Array>
- </mx:dataProvider>
- </mx:ComboBox>
- </mx:FormItem>
- <mx:FormItem label="horizontalTickAligned:">
- <mx:CheckBox id="hCheckBox" selected="true" />
- </mx:FormItem>
- <mx:FormItem label="verticalTickAligned:">
- <mx:CheckBox id="vCheckBox" selected="true" />
- </mx:FormItem>
- </mx:Form>
- </mx:ApplicationControlBar>
- <mx:LineChart id="lineChart"
- showDataTips="true"
- dataProvider="{dp}"
- width="100%"
- height="100%">
- <!-- background elements -->
- <mx:backgroundElements>
- <mx:GridLines direction="{comboBox.selectedItem.label}"
- horizontalTickAligned="{hCheckBox.selected}"
- verticalTickAligned="{vCheckBox.selected}">
- <mx:horizontalFill>
- <mx:SolidColor color="haloBlue" alpha="0.2" />
- </mx:horizontalFill>
- <mx:horizontalAlternateFill>
- <mx:SolidColor color="haloSilver" alpha="0.2" />
- </mx:horizontalAlternateFill>
- <mx:verticalFill>
- <mx:SolidColor color="haloBlue" alpha="0.2" />
- </mx:verticalFill>
- <mx:verticalAlternateFill>
- <mx:SolidColor color="haloSilver" alpha="0.2" />
- </mx:verticalAlternateFill>
- </mx:GridLines>
- </mx:backgroundElements>
- <!-- vertical axis -->
- <mx:verticalAxis>
- <mx:LinearAxis baseAtZero="false"
- title="Price"
- labelFunction="linearAxis_labelFunc" />
- </mx:verticalAxis>
- <!-- horizontal axis -->
- <mx:horizontalAxis>
- <mx:CategoryAxis id="ca"
- categoryField="@date"
- title="August 2007"
- labelFunction="categoryAxis_labelFunc" />
- </mx:horizontalAxis>
- <!-- horizontal axis renderer -->
- <mx:horizontalAxisRenderers>
- <mx:AxisRenderer axis="{ca}" canDropLabels="true" />
- </mx:horizontalAxisRenderers>
- <!-- series -->
- <mx:series>
- <mx:LineSeries yField="@open" displayName="Open" />
- <mx:LineSeries yField="@close" displayName="Close" />
- </mx:series>
- <!-- series filters -->
- <mx:seriesFilters>
- <mx:Array />
- </mx:seriesFilters>
- </mx:LineChart>
- </mx:Application>
代码:Peter deHaan 翻译/整理/编译:中文Flex例子
Flex中如何通过horizontalTickAligned和verticalTickAligned样式指定线图LineChart横竖方向轴心标记的例子的更多相关文章
- 点线图中的A*算法
A*简介 A*(A-Star)算法是一种启发式算法,是静态路网中求解最短路最有效的方法.公式表示为:f(n)=g(n)+h(n), 其中f(n) 是节点n从初始点到目标点的估价函数, g(n) 是在状 ...
- Flex中使用CSS控制页面样式
Using file: Stylebounding.mxml Stylebounding2.mxml myCSS0329.css 在Flex4中使用CSS控制样式,既可以直接在MXML文件中写样式,也 ...
- Flex中如何通过设置GridLines对象的horizontalAlternateFill样式交错显示LineSeries图表背景颜色的例子
原文 http://blog.minidx.com/2008/11/27/1652.html 接下来的例子演示了Flex中如何通过设置GridLines对象的horizontalAlternateFi ...
- 找到一个Flex中LineChart很好的学习博客
http://blog.flexexamples.com/category/linechart/ 里面链接复制的时候失效了,请直接点击原页面进行查看 Setting specific minimum ...
- Flex中的折线图
1.问题背景 在Flex中,制作一个折线图.而且给折线图的横轴和纵轴进行样式设置,详细实现过程例如以下: 2.实现实例 (1)设置横轴样式和数据绑定 <mx:horizontalAxis> ...
- CSS中常见的6种文本样式
前面的话 CSS文本样式是相对于内容进行的样式修饰.由于在层叠关系中,内容要高于背景.所以文本样式相对而言更加重要.有些人对文本和字体样式之间的不同不太了解,简单地讲,文本是内容,而字体则用于显示这个 ...
- Flex中设置Camera的视频清晰质量的最佳配合
今天需要设置Flex中的Camera组件的一些属性,后来发现清晰度不是很高,于是捣鼓了上午半天,设置了很多的参数,竟然发现手册上就是有现成的一些设置方法,郁闷!不过我还是专门设置了几个有用和必要的属性 ...
- ArcGIS for Flex中引入google map作底图
上篇文章到在ArcGIS View中引入google map,这里讲ArcGIS for Flex中引入google map作底图. 同样道理,以google map作底图,需要编写继承自TiledM ...
- AS与JS相互通信(Flex中调用js函数)
转载自http://www.blogjava.net/Alpha/archive/2009/06/27/284373.html Flex中As调用Js的方法是: 1.导入包 (import f ...
随机推荐
- Oracle之PLSQL总结
基本数据类型变量 1. 基本数据类型 Number 数字型 Int 整数型 Pls_integer 整数型,产生溢出时出现错误 Binary_integer 整数型,表示带符号 ...
- C语言基础07
结构体与函数的区别: 1.函数是由相同数据类型的变量组成. 2.结构体可以有不同数据类型组合.可以包含char,int,float,数组等类型. struct 结构名称 { 数据类型 成员: 注意 ...
- SQL Server 连接和事务相关的问题。
方法 1. dbcc opentran + sys.dm_exec_connections dbcc opentran; dbcc opentran 针对当前数据库 dbcc opentran('St ...
- Can someone explain Webpack's CommonsChunkPlugin
I get the general gist that the CommonsChunkPlugin looks at all the entry points, checks to see if t ...
- 'adb' 不是内部或外部命令,也不是可运行的程序
启动adb shell的时候,出现如下问题: 'adb' 不是内部或外部命令,也不是可运行的程序或批处理文件. 在确保自己的SDK安装正确的时候,就很好办了,找到SDK安装目录\platform-to ...
- how to remove MouseListener / ActionListener on a JTextField
I have the following code adding an ActionListener to a JTextField: chatInput.addMouseListener(new j ...
- python官方文档
Tutorialstart here Library Referencekeep this under your pillow Language Referencedescribes syntax a ...
- 电子科大POJ "敲错键盘"
C-sources: #include<stdio.h> #define N 20 int main() { int i,j; ]={'Q','W','E','R','T','Y','U' ...
- virtualbox 复制多个虚拟机 (宿主机redhat)
我用VirtualBox做了一个winxp虚拟镜像. 想实现不重新安装而直接复制几个,也就是同时装载几个虚拟机. 但是直接复制已安装好机子的vdi文件,系统会报uuid已存在的错误. 所以,就需要修改 ...
- Iphone JS时间
var end_time = new Date(time).getTime();//月份是实际月份-1 var start_time= new Date(serverTime).getTime(); ...