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. Retrieving failed records after an SqlBulkCopy exception

    Let me start by saying that the idea I used in this article is not originally mine, but since I have ...

  2. 深入浅出SharePoint——获取Choice Field的Mapping value

    list field对应的caml定义如下 <Field Type="Choice" DisplayName="Inspection Result" Re ...

  3. [EffectiveC++]item22:Declare data members private

    将成员变量隐藏在函数接口的背后,可以为“所有可能的实现”提供弹性, 假设我们有一个public成员变量,而我们最终取消了它,多少代码可能会被破坏呢?那是一个不可知的大量. protected成员变量就 ...

  4. 列表:List<T>与HashSet和只读集合

    一.概述 List<T> 是ArrayList类的等效泛型类.属System.Collections.Generic命名空间. 二.声明及初始化 1.List<T> mList ...

  5. lvs安装文档

    安装lvs应用模块 1.安装依赖包: [root@client lvs]# yum -y install ipvs* 2.验证本机ip_vs模块是否加载 [root@client lvs]# -.el ...

  6. 环信REST API python SDK

    今天鼓起勇气,决定把这个贡献出来.不敢误人子弟,也一直担心,在不良质量的产品会祸害人,但自己已经使用,它本身也没技术. 平庸的代码,高效地实用,为环信贡献点力,如有问题,欢迎斧正,一起学习,一起成长, ...

  7. python连接数据库并插入数据

    1.Python创建数据库 import MySQLdb try: conn = MySQLdb.connect( host="127.0.0.1", port=3306, use ...

  8. php数组的定义和数组的赋值

    1.php执行过程 加载页面  语法检测 执行脚本 $arr=array(1,2,3); 索引数组 $arr=array("name"=>"user1", ...

  9. html5物理定位误差大 解决办法

    学生党在做比赛作品,项目中需求要用到定位功能并以地图形式展现.所以思路就是用h5的geolocation 获取经纬度,通过百度地图api将经纬度转换成详细的地址以及地图.在笔记本电脑做测试,定位总有超 ...

  10. Golang测试包

    Golang测试包 golang自带了测试包(testing),直接可以进行单元测试.性能分析.输出结果验证等.简单看着官方文档试了试,总结一下: 目录结构和命令 使用golang的测试包,需要遵循简 ...