国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網(wǎng)站 > WEB開發(fā) > 正文

16.5.為圖表創(chuàng)建自定義標簽

2024-04-27 13:52:22
字體:
來源:轉載
供稿:網(wǎng)友
16.5.1. 問題
我想自定義圖表的標簽。
16.5.2. 解決辦法
使用樣式和標簽函數(shù)。
16.5.3. 討論
圖表中包含兩種類型的標簽:坐標軸標簽和數(shù)據(jù)標簽。坐標軸標簽用于顯示坐標軸上的點的數(shù)值,使用標簽函數(shù)能自定義坐標軸標簽。數(shù)據(jù)標簽用于在數(shù)據(jù)點的位置和圖表元素的位置顯示數(shù)據(jù)值。

使用坐標軸標簽可以很大程度上控制坐標軸標簽的形式。例如你需要特殊的數(shù)據(jù)格式或者通用的格式,就可以使用標簽函數(shù)。標簽函數(shù)通用適用與數(shù)據(jù)標簽。

標簽函數(shù)對于數(shù)字坐標軸、分類坐標軸和數(shù)列的用法略有不同,如下所示。
數(shù)字坐標軸的標簽函數(shù)有如下寫法::
+展開
-ActionScript
function_name(labelValue:Object, previousLabelValue:Object, axis:IAxis):String


其參數(shù)如下:
labelValue
當前標簽的數(shù)值;
previousLabelValue
該標簽之前的一個標簽的值。如果當前標簽是第一個標簽,那么previousLabelValue 的值就是null。
axis
坐標軸對象,和CategoryAxis 或者NumericAxis 對象相似。

分類坐標軸的標簽函數(shù)有如下寫法:
+展開
-ActionScript
function_name(labelValue:Object, previousLabelValue:Object, axis:axis_type,labelItem:Object):String

categoryValue
要描繪的類別的值。
previousCategoryValue
在坐標軸上前一個類別的值
axis
正在渲染的類別坐標軸的值。
categoryItem
當前描繪的數(shù)據(jù)提供器提供的項目

以下例子使用了一個CurrencyFormatter 來為縱坐標標簽和數(shù)據(jù)標簽定義格式
+展開
-XML
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="horizontalbackgroundColor="0xFFFFFF"
initialize="onInit()">

<mx:Script>
<![CDATA[
import mx.charts.chartClasses.Series;
import mx.charts.ChartItem;
import mx.charts.chartClasses.IAxis;
import mx.formatters.CurrencyFormatter;
[Bindable] public var chartDP:Array = [
{month:'Jan',costs:10000,sales:100000},
{month:'Feb',costs:7000,sales:220000},
{month:'Mar',costs:5000,sales:540000},
{month:'April',costs:8000,sales:60000},
{month:'May',costs:11000,sales:390000},
{month:'June',costs:12000,sales:790000},
{month:'July',costs:14000,sales:1220000}
];
private var formatter:CurrencyFormatter;
private function onInit():void
{
formatter = new CurrencyFormatter();
formatter.currencySymbol = '$';
formatter.precision = 0;
formatter.useThousandsSeparator = true;
}
private function currencyAxisLabel(value:Object,
previousValue:Object, axis:IAxis):String
{
return formatter.format(value);
}

]]>
</mx:Script>
<mx:LineChart dataProvider="{chartDP}" >
<mx:horizontalAxis>
<mx:CategoryAxis dataProvider="{chartDP}categoryField="month" />
</mx:horizontalAxis>
<mx:verticalAxis>
<mx:LinearAxis labelFunction="{currencyAxisLabel}" />
</mx:verticalAxis>
<mx:series>
<mx:LineSeries yField="costsxField="monthdisplayName="Costs" />
</mx:series>
</mx:LineChart>
</mx:Application>
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 额敏县| 咸宁市| 怀化市| 英山县| 冷水江市| 泽普县| 博客| 图木舒克市| 工布江达县| 乐东| 宜兴市| 郎溪县| 博白县| 合江县| 大埔县| 重庆市| 德江县| 汉源县| 孟津县| 安达市| 凤山市| 那坡县| 历史| 晴隆县| 朝阳区| 山东省| 丽水市| 四会市| 鲁山县| 枣庄市| 桐乡市| 华安县| 田东县| 滁州市| 顺义区| 分宜县| 饶平县| 南京市| 尼木县| 乡城县| 江油市|