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

首頁 > 網站 > WEB開發 > 正文

16.5.為圖表創建自定義標簽

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

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

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


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

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

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

以下例子使用了一個CurrencyFormatter 來為縱坐標標簽和數據標簽定義格式
+展開
-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>
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 岳阳县| 平罗县| 松原市| 东乡族自治县| 奉新县| 平凉市| 延庆县| 汨罗市| 临汾市| 景德镇市| 涪陵区| 泾源县| 广汉市| 顺昌县| 调兵山市| 靖江市| 平谷区| 泗水县| 内丘县| 中西区| 石首市| 娱乐| 济宁市| 南宫市| 贺州市| 综艺| 东乡族自治县| 垣曲县| 宁武县| 若尔盖县| 河曲县| 江口县| 柘城县| 偃师市| 法库县| 龙陵县| 斗六市| 白山市| 和林格尔县| 万盛区| 琼海市|