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. December 16th 2016 Week 51st Friday

    My life is a straight line, turning only for you. 我的人生是一条直线,转弯只是为了你. My life is a straight line that ...

  2. 51nod 1349 最大值

    题目看这里 找到每个元素g[i]作为最大值的区间[L,R],那么以他为最大值的区间数有(i-L+1)*(R-i+1)个. 为了加速,以k为最大值的区间数放入H[k],再以此统计一个前缀和,更新入H.那 ...

  3. iOS 滑动比较

    对iOS手机进行滑动操作进行总结:1.mobile:scroll向下滚动整个屏幕driver.execute_script('mobile: scroll', {'direction': 'down' ...

  4. [转载] c++对结构体数组排序

    按结构体中某个成员进行排序,下面代码以成员b1为升序的排序 代码: #include<iostream> #include<algorithm> using namespace ...

  5. 微服务、rest/restful、springmvc、http简要梳理

    微服务简介 微服务是一个新兴的软件架构,就是把一个大型的单个应用程序和服务拆分为数十个的支持微服务.一个微服务的策略可以让工作变得更为简便,它可扩展单个组件而不是整个的应用程序.简而言之,微服务架构是 ...

  6. Web App, Native APP,Hybird App 介绍

    一.Web App 这个主要是采用统一的标准的 HTML,JavaScript.CSS 等 web 技术开发. 用户无需下载,通过不同平台 的浏览器访问来实现跨平台, 同时可以通过浏览器支持充分使用 ...

  7. 死磕salt系列-salt配置文件

    这篇文件主要用来解释一下salt配置中常用的参数,其他的参数可以参考官网文档. 基础参数 interface: 服务器监听地址. ipv6: 是否启用ipv6. max_open_files: 最大文 ...

  8. 【NOIP2014】解方程

    题目描述 已知多项式方程 \[a_0 + a_1x + a_2x^2 + \dots +a_nx^n=0\] 求这个方程在\([1,m]\)内的整数解(\(n\)和\(m\)均为正整数). 输入输出格 ...

  9. Pymyaql操作数据库

    Pymyaql操作数据库 Python3中专门用于操作Mysql数据库的模块. 一. 导入模块 import pymysql 二. 创建连接 conn=pymysql.connect(host=’12 ...

  10. nRF5 SDK for Mesh(六) BLE MESH 的 基础概念

    Basic Bluetooth Mesh concepts The Bluetooth Mesh is a profile specification developed and published ...