Using a custom AxisRenderer object

http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7c39.html

 

 

To change the appearance of the axis labels, you can use thelabelRendererproperty of the AxisRenderer class. This lets you specify a class that defines the appearance of the label. The class must extend UIComponent and implement the IDataRenderer and IFlexDisplayObject interfaces. Itsdataproperty will be the label used in the chart. Typically, you write an ActionScript class that extends the ChartLabel class for the label renderer.

The following example defines a custom component inline by using the<fx:Component>tag. It adds ToolTip objects to the labels along the chart’s horizontal axis so that the values of the longer labels are not truncated.

<?xml version="1.0"?>
<!-- charts/LabelRendererWithToolTips.mxml -->
<s:Application
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:s="library://ns.adobe.com/flex/spark"
initialize="setupDP()"
width="550" height="600"> <fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.charts.ColumnChart; [Bindable]
private var ac:ArrayCollection; public function setupDP():void{
ac = new ArrayCollection([
[ "Label 1 is short.", 200000],
[ "Label 2 is a fairly long label.", 150000],
[ "Label 3 is an extremely long label. It contains 95 characters " +
"and will likely be truncated.", 40000]
]);
}
]]>
</fx:Script> <s:layout>
<s:VerticalLayout/>
</s:layout> <s:Panel title="Column Chart">
<s:layout>
<s:VerticalLayout/>
</s:layout>
<mx:ColumnChart id="bc1"
showDataTips="true"
dataProvider="{ac}">
<mx:series>
<mx:ColumnSeries xField="0" yField="1"/>
</mx:series>
<mx:verticalAxis>
<mx:LinearAxis id="va1"/>
</mx:verticalAxis>
<mx:horizontalAxis >
<mx:CategoryAxis id="ha1"
dataProvider="{ac}"
categoryField="0"/>
</mx:horizontalAxis>
<mx:horizontalAxisRenderers>
<mx:AxisRenderer axis="{ha1}" canDropLabels="false">
<mx:labelRenderer>
<fx:Component>
<mx:Label toolTip="{this.myTip}">
<fx:Script><![CDATA[
[Bindable]
private var myTip:String; override public function set data(value:Object):void{
if(value == null)
return;
myTip = value.text;
var length:int = value.text.toString().length;
if (length > 20) {
text = value.text.toString().substr(0, 20) + "...";
} else {
text = value.text;
}
}
]]></fx:Script>
</mx:Label>
</fx:Component>
</mx:labelRenderer>
</mx:AxisRenderer>
</mx:horizontalAxisRenderers>
<mx:verticalAxisRenderers>
<mx:AxisRenderer axis="{va1}" canDropLabels="false"/>
</mx:verticalAxisRenderers>
</mx:ColumnChart>
<s:Label id="l1"
color="white"
text="Hover over the horizontal axis's labels to see the entire title rendered as a ToolTip."/>
</s:Panel>
</s:Application>

The executing SWF file for the previous example is shown below:

 

For an example of an ActionScript class that extends ChartLabel, see Adding axis titles.

Using a custom AxisRenderer object的更多相关文章

  1. 【IOS笔记】Creating Custom Content View Controllers

    Creating Custom Content View Controllers 自定义内容视图控制器 Custom content view controllers are the heart of ...

  2. Implement Custom Cache Dependencies in ASP.NET 1.x

    Code download available at:CuttingEdge0407.exe(128 KB)   Contents What's a Cache Dependency, Anyway? ...

  3. Collection View Programming Guide for iOS---(六)---Creating Custom Layouts

    Creating Custom Layouts 创建自定义布局 Before you start building custom layouts, consider whether doing so ...

  4. View Controller Programming Guide for iOS---(四)---Creating Custom Content View Controllers

    Creating Custom Content View Controllers 创建自定义内容视图控制器 Custom content view controllers are the heart ...

  5. How to: Create Custom Configuration Sections Using ConfigurationSection

    https://msdn.microsoft.com/en-us/library/2tw134k3.aspx You can extend ASP.NET configuration settings ...

  6. 解析大型.NET ERP系统数据访问 对象关系映射框架LLBL Gen Pro

    LLBL Gen Pro是一个为.NET开发人员设计的的对象关系映射(ORM)框架,与NHibernate,Entity Framework等框架一样,通过实体与数据表的映射,实现关系数据库持久化. ...

  7. AMD高级应用(翻译)

    Dojo now supports modules written in the Asynchronous Module Definition (AMD) format, which makes co ...

  8. Xamarin.Forms介绍

    On May 28, 2014, Xamarin introduced Xamarin.Forms, which allows you to write user-interface code tha ...

  9. 【IOS笔记】Delegation

    Delegation Delegation is a simple and powerful pattern in which one object in a program acts on beha ...

随机推荐

  1. Jenkins在CentOS中的安装

    环境准备: tomcat,jdk 包准备:Jenkins的war包,下载路径:https://jenkins.io/download/ 把下载好的war包放在tomcat的webapps中,重启tom ...

  2. mongd配置文件解释

    mongd配置文件解释 系统日志配置 systemLog: verbosity: <int> quiet: <boolean> traceAllExceptions: < ...

  3. BZOJ1058:[ZJOI2007]报表统计(Splay,堆)

    Description 小Q的妈妈是一个出纳,经常需要做一些统计报表的工作.今天是妈妈的生日,小Q希望可以帮妈妈分担一些工 作,作为她的生日礼物之一.经过仔细观察,小Q发现统计一张报表实际上是维护一个 ...

  4. JavaScript脚本的执行原理?

    JavaScript是一种动态.弱类型.基于原型的语言,通过浏览器可以直接执行. 当浏览器遇到\<script>标记的时候,浏览器会执行之间的JavaScript代码.嵌入的js代码是顺序 ...

  5. 401. Binary Watch 回溯

    A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom ...

  6. 在hyper-v中安装centos后配置网络

    /etc/sysconfig/network-scripts vi ifcfg-eth0 改为以下配置 TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no ...

  7. SpringBoot+MyBatis中自动根据@Table注解和@Column注解生成ResultMap

    其实我一点都不想用mybatis,好多地方得自己写,比如这里. 使用mybatis要写大量的xml,烦的一批.最烦人的莫过于写各种resultmap,就是数据库字段和实体属性做映射.我认为这里应该是m ...

  8. jFinal 2.2入门学习之一:搭建框架输出helloword

    官方推荐用Eclipse IDE for Java EE Developers 做为开发环境 1.创建 Dynamic Web Project 2.修改 Default Output Folder,推 ...

  9. 通过nat让内网机器上网

    让内网机器访问不通机房的机器,架构如下 (172.16.10.5)  ----- (172.17.9.109 可以出外网,开启路由转发)  -------  (内网 192.168.36.19 能pi ...

  10. oracle的建表语句

    oracle数据库的建表语句,具体语法如下: CREATE TABLE tablename (column_name datatype [null,not null], column_name dat ...