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. August 19th 2017 Week 33rd Saturday

    Live for today and stop stressing out about tomorrow. 为今天而活,不必为明天过分担心. Stop bewailing the past misfo ...

  2. python_4程序设计基础

    1注释 2变量和常量 3命名 4表达式 5赋值语句

  3. Spring配置文件中的parent与abstract

    在看项目的Spring配置文件时,发现消息队列的配置采用了继承方式配置Bean,在这梳理总结一下. 其实在基于spring框架开发的项目中,如果有多个bean都是一个类的实例,如配置多个数据源时,大部 ...

  4. python接口测试-项目实践(八) 完成的接口类和执行脚本

    脱敏后脚本 projectapi.py: 项目接口类 # -*- coding:utf-8 -*- """ xx项目接口类 2018-11 dinghanhua &quo ...

  5. 死磕salt系列-salt 配置文件管理

    SLS是Salt State系统的核心,用来描述系统的目标状态,使用YAML语言书写.被用作配置文件管理. SLS文件 sls配置文件分为两种类型 top.sls 这是所有配置文件的入口 sls 这是 ...

  6. 一步步入门编写PHP扩展

    1.写在最前 随着互联网飞速发展,lamp架构的流行,php支持的扩展也越来越多,这样直接促进了php的发展. 但是php也有脚本语言不可避免的问题,性能比例如C等编译型语言相差甚多,所以在考虑性能问 ...

  7. WEB安全 php+mysql5注入防御(二)

    第四天: 一.新的注入函数: ascii() substring("string",n,m)                     n>=1 limit n,m      ...

  8. Nginx学习之从零搭建静态资源网站

    前言   在某学习网站学习了nginx的安装和使用,以此文记录. 环境准备   安装在VMWare下的Centos虚拟机.由于我这是新装的虚拟机.所以很多插件都没有,这里干脆一次性安装上. wget ...

  9. sqoop导数据到hive报错

    [root@hadoop1 conf]# sqoop import --connect jdbc:mysql://192.168.122.15:3306/company --username sqoo ...

  10. CS20Chapter2

    constants操作 import tensorflow as tf a = tf.constant([2, 2], name='a') b = tf.constant([[0, 1], [2, 3 ...