//flex用例网址

http://thanksmister.com/2012/01/18/flex-chart-datatip-renderer/

http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf65c3d-7fff.html#WS2db454920e96a9e51e63e3d11c0bf69084-7c10

main.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:Application
 xmlns:mx="http://www.adobe.com/2006/mxml"
 xmlns:slc="com.scottlogic.charts.*"
 layout="horizontal"
 width="400"
 height="300"
 viewSourceURL="srcview/index.html"
 >
 <mx:Script>
  <![CDATA[
   import mx.charts.series.items.ColumnSeriesItem;
   import mx.charts.series.ColumnSeries;
   import mx.charts.HitData;
   import mx.collections.ArrayCollection;
   
   [Bindable]
   public var sales:ArrayCollection = new ArrayCollection([
    {period: "Q1", toys: 900, electronics: 300, clothes: 400},
    {period: "Q2", toys: 200, electronics: 600, clothes: 450},
    {period: "Q3", toys: 500, electronics: 300, clothes: 200},
    {period: "Q4", toys: 800, electronics: 100, clothes: 300}
   ]);
   
   /**
    *
    */
   private function myDataTipFunction(hitData:HitData):String
   {
    var series:ColumnSeries = ColumnSeries(hitData.element);
    var item:ColumnSeriesItem = ColumnSeriesItem(hitData.chartItem);
    var quarter:Object = xAxis.formatForScreen(item.xValue);
    var total:Number = columnSet.positiveTotalsByAxis[item.xValue];
    var value:Number = Number(item.yValue) - Number(item.minValue);
    var percent:Number = Math.round(value / total * 1000) / 10; // want 2 decimal place precision
    return "In <b>" + quarter + "</b> there were <b>" + value + " "
     + series.displayName + "</b> units sold.<br/>This is <b>"
     + percent + "%</b> of the <b>" + total + " total</b> units sold in "
     + quarter + ".";
   }
  ]]>
 </mx:Script>
 
 <mx:ColumnChart
  dataProvider="{sales}"
  width="100%"
  height="100%"
  showDataTips="true"
  dataTipFunction="myDataTipFunction"
  >
  <mx:horizontalAxis>
   <mx:CategoryAxis id="xAxis" categoryField="period" />
  </mx:horizontalAxis>
  <mx:verticalAxis>
   <mx:LinearAxis id="yAxis" />
  </mx:verticalAxis>
  <mx:series>
   <slc:ColumnSet id="columnSet" type="stacked">
    <mx:ColumnSeries yField="toys" displayName="Toys" />
    <mx:ColumnSeries yField="electronics" displayName="Electronics" />
    <mx:ColumnSeries yField="clothes" displayName="Clothes" />
   </slc:ColumnSet>
  </mx:series>
 </mx:ColumnChart>
 
</mx:Application>

ColumnSet.as

package com.scottlogic.charts
{
    import flash.utils.Dictionary;
    import mx.charts.series.ColumnSet;
   
    /**
     * Extension to mx.charts.series.ColumnSet to expose the
     * stack totals for public use, e.g. in a data tip
     * function.
     */
    public class ColumnSet extends mx.charts.series.ColumnSet
                           implements IStackedSeries
    {
        /**
         * Constructor
         */
        public function ColumnSet()
        {
            super();
        }
       
        /**
         * @see IStackedSeries.positiveTotalsByAxis
         */
        public function get positiveTotalsByAxis():Dictionary
        {
            return posTotalsByPrimaryAxis;
        }
       
        /**
         * @see IStackedSeries.negativeTotalsByAxis
         */
        public function get negativeTotalsByAxis():Dictionary
        {
            return negTotalsByPrimaryAxis;
        }
       
        /**
         * @see IStackedSeries.stackMaximum
         */
        public function get stackMaximum():Number
        {
            return stackedMaximum;
        }
       
        /**
         * @see IStackedSeries.stackMinimum
         */
        public function get stackMinimum():Number
        {
            return stackedMinimum;
        }
    }
}

flex 自定义tooltip的更多相关文章

  1. Flex自定义组件开发之日周月日期选择日历控件

    原文:Flex自定义组件开发之日周月日期选择日历控件         使用过DateField的我们都知道,DateField 控件是用于显示日期的文本字段,字段右侧带有日历图标.当用户在控件边框内的 ...

  2. Flex自定义组件、皮肤,并调用

    标签:Flex  自定义组件  自定义皮肤  主应用调用模块 本程序样例学习自flex 实战教程.但因原教程代码不全,且根据个人需求有更改. 1文件列表 自定义as类Reveal.as,该类实现组件的 ...

  3. flex 自定义组件的编写

    使用flex也很久了,也改过别人写的flex自定义组件,但是就是没有系统的研究下flex组件的编写步骤,和要注意的东西,在这里我参照一本书中的例子,好好的理解下,也为了巩固下自己对flex的理解! 1 ...

  4. echarts自定义tooltip提示框内容

    1.echarts自定义tooltip提示框内容 https://blog.csdn.net/dreamsup/article/details/56667330 2.关于Echarts的formatt ...

  5. DevExpress.XtraGrid.GridControl 实现自定义tooltip

    DevExpress.XtraGrid.GridControl 控件默认的tooltip显示的每一个单元格的文本值,但是实际工作中会出现各种需求.我这里就有一个列是折扣率显示的值是0-1之间的两位小数 ...

  6. Flex 自定义事件

    一.分派自定义事件类型 任何实现flash.event.IEventDispatcher接口的对象都可以分派事件,这包括所有显示对象和一些非显示对象类.通常,对于 自定义的非显示类,可以通过扩展fla ...

  7. flex自定义preloader预加载进度条

    flex默认的preloader已经很不错了,可是有时候还是需要自定义的.   需要在要出现自定义预加载的程序的<mx:Application>标签里加入preloader="& ...

  8. Flex 自定义 Zlert 组件!

    说明: 原生的 Alert.show 参数,要显示的按钮你只能 Alert.OK | Alert.Cancel 这样; 自定义 Zlert 参数跟原生的 差不多,按钮写法是这样写的: {"b ...

  9. Flex 自定义打印控件编写

    打印历来是web应用一个比较棘手的问题,幸好flex web应用是运行在flash player上的,flash player可以访问打印机,所以flex 应用可以实现比较强大的打印功能.Flex 自 ...

随机推荐

  1. 错误:该表单无法显示,可能是由于 Microsoft SharePoint Server State Service 配置不当。有关详细信息,请与服务器管理员联系

    问题场景: 1.SharePoint 2013 中工作流需要状态服务(State Service),如果没有正确配置状态服务,则在给列表.文档库添加工作流时会遇到错误: “该表单无法显示,可能是由于 ...

  2. [19/05/02-星期四] GOF23_行为型模式(状态模式、观察者模式、备忘录模式)

    一.状态模式 [状态接口] /*** * 房间"状态"接口 */ package cn.sxt.state; public interface State { void handl ...

  3. 组合测试(Combinatorial Test)/配对测试 (pairwise)

    组合测试方法:配对测试实践 实施组合测试 常用的Pairwise工具集:http://www.pairwise.org/tools.asp 成对测试(Pairwise Testing)又称结对测试.两 ...

  4. 3.C++和C混合编程

    最近经常看到头文件中有 #ifdef __cplusplus extern "C" { #endif ....... #ifdef __cplusplus } #endif 这样的 ...

  5. Ubuntu安装MySQL/MariaDB

    安装MariaDB/MySQL MariaDB是MySQL的分支,与MySQL高度兼容,几乎所有的命令都一样.MariaDB是由前MySQL的开发人员离开Sun公司后开发的,目的是为了防止Oracle ...

  6. unittest 测试

    unittest 测试 单元测试是用来对一个模块.一个函数或者一个类来进行正确性检验的测试工作. 比如对函数abs(),我们可以编写出以下几个测试用例: 输入正数,比如1.1.2.0.99,期待返回值 ...

  7. nginx开启gzip

    gzip on; gzip_min_length 5k; gzip_buffers 4 16k; #gzip_http_version 1.0; gzip_comp_level 3; gzip_typ ...

  8. 404 Note Found 队-Alpha9

    目录 组员情况 组员1(组长):胡绪佩 组员2:胡青元 组员3:庄卉 组员4:家灿 组员5:凯琳 组员6:翟丹丹 组员7:何家伟 组员8:政演 组员9:黄鸿杰 组员10:刘一好 组员11:何宇恒 展示 ...

  9. cocos2d-x开发: 完善接口范例分离模块

    在上一篇文章中,我阐述了一下为什么要做分离这种工作,这篇文章没什么重点,只是将上一次没有完善的工作做完.原本我想做到像Lua-tests那样子,能够一次完全显示所有的tests,然后选择要执行的tes ...

  10. 使用XWAF框架(4)——LunarCalendar日历组件

    XWAF提供了管理日历的com.xwaf.date.LunarCalendar静态类,可以直接使用,非常方便.该类包括六个主要静态方法: 4.1  isLeapYear(int year) 判断公历年 ...