適用於 Adobe® Flash® Platform 的 ActionScript® 3.0 參考
首頁  |  隱藏套件和類別清單 |  套件  |  類別  |  新增內容  |  索引  |  附錄  |  為什麼顯示英文?
篩選: 從伺服器擷取資料...
從伺服器擷取資料...
mx.charts 

CategoryAxis  - AS3 Flex

套件mx.charts
類別public class CategoryAxis
繼承CategoryAxis Inheritance AxisBase Inheritance EventDispatcher Inheritance Object
實作 IAxis

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

The CategoryAxis class lets charts represent data grouped by a set of discrete values along an axis. You typically use the CategoryAxis class to define a set of labels that appear along an axis of a chart. For example, charts that render data according to City, Year, Business unit, and so on.

You are not required to explicitly set the dataProvider property on a CategoryAxis. A CategoryAxis used in a chart inherits its dataProvider property from the containing chart.

While you can use the same data provider to provide data to the chart and categories to the CategoryAxis, a CategoryAxis can optimize rendering if its data provider is relatively static. If possible, ensure that the categories are relatively static and that changing data is stored in separate data providers.

The dataProvider property can accept either an array of strings or an array of records (Objects) with a property that specifies the category name. If you specify a categoryField property, the CategoryAxis assumes that the data provider is an array of Objects. If the value of the categoryField property is null, the CategoryAxis assumes that the data provider is an array of Strings.

MXML 語法expanded隱藏 MXML 語法

The <mx:CategoryAxis> tag inherits all the properties of its parent classes and adds the following properties:

  <mx:CategoryAxis
    Properties
    categoryField="null"
    dataFunction="No default"
    dataProvider="No default"
    labelFunction="No default"
    padding="Default depends on chart type"
    ticksBetweenLabels="true"
  />
  

檢視範例

更多範例



公用屬性
 屬性定義自
  baseline : Number
[唯讀] The baseline position for the axis.
CategoryAxis
  categoryField : String
Specifies the field of the data provider containing the text for the labels.
CategoryAxis
 InheritedchartDataProvider : Object
[唯寫] The data provider assigned to the enclosing chart.
AxisBase
 Inheritedconstructor : Object
類別物件的參照或是特定物件實體的建構函數。
Object
  dataFunction : Function
Specifies a method that returns the value that should be used as categoryValue for current item.If this property is set, the return value of the custom data function takes precedence over categoryField The custom dataFunction has the following signature: function_name (axis:CategoryAxis, item:Object):Object { ...
CategoryAxis
  dataProvider : Object
Specifies the data source containing the label names.
CategoryAxis
 InheriteddisplayName : String
The name of the axis.
AxisBase
  labelFunction : Function
Specifies a function that defines the labels that are generated for each item in the CategoryAxis's dataProvider.
CategoryAxis
  padding : Number
Specifies the padding added to either side of the axis when rendering data on the screen.
CategoryAxis
  ticksBetweenLabels : Boolean
Specifies the location of major tick marks on the axis, relative to the category labels.
CategoryAxis
 Inheritedtitle : String
The text for the title displayed along the axis.
AxisBase
 InheritedunitSize : Number
[唯讀] The size of one unit of data as represented by this axis.
AxisBase
公用方法
 方法定義自
  
Constructor.
CategoryAxis
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
會在 EventDispatcher 物件註冊事件偵聽程式,以便讓偵聽程式收到事件的通知。
EventDispatcher
 Inherited
Triggers events that inform the range object when the chart data has changed.
AxisBase
 Inherited
會將事件傳送到事件流程。
EventDispatcher
  
filterCache(cache:Array, field:String, filteredField:String):void
Filters a set of values of arbitrary type to a set of numbers that can be mapped.
CategoryAxis
  
Formats values for display in DataTips.
CategoryAxis
  
Determines the range to estimate what the axis labels should be.
CategoryAxis
  
getLabels(minimumAxisLength:Number):AxisLabelSet
Gets the labels text that is rendered.
CategoryAxis
 Inherited
會檢查 EventDispatcher 物件是否有對特定的事件類型註冊偵聽程式。
EventDispatcher
 Inherited
指出物件是否有已定義的指定屬性。
Object
  
Maps a position along the axis back to a numeric data value.
CategoryAxis
 Inherited
指出 Object 類別的實體是否位於指定為參數的物件原型鏈中。
Object
  
mapCache(cache:Array, field:String, convertedField:String, indexValues:Boolean = false):void
Converts a set of values of arbitrary type to a set of numbers that can be transformed into screen coordinates.
CategoryAxis
  
Determines how the axis handles overlapping labels.
CategoryAxis
 Inherited
指出指定的屬性是否存在,以及是否可列舉。
Object
  
reduceLabels(intervalStart:AxisLabel, intervalEnd:AxisLabel):AxisLabelSet
Invoked when an AxisRenderer is unable to cleanly render the labels without overlap, and would like the Axis object to reduce the set of labels.
CategoryAxis
 Inherited
Each DataTransform that makes use of an axis registers itself with that axis.
AxisBase
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
會從 EventDispatcher 物件移除偵聽程式。
EventDispatcher
 Inherited
為迴圈作業設定動態屬性的可用性。
Object
 Inherited
傳回代表此物件的字串,根據地區特定慣例進行格式化。
Object
 Inherited
會傳回指定之物件的字串形式。
Object
  
transformCache(cache:Array, field:String, convertedField:String):void
Maps a set of values from data space to screen space.
CategoryAxis
 Inherited
Each DataTransform that makes use of an axis registers itself with that axis.
AxisBase
  
Updates the chart.
CategoryAxis
 Inherited
會傳回指定之物件的基本值。
Object
 Inherited
檢查此 EventDispatcher 物件是否已註冊事件偵聽程式,或者此物件的任何祖系已為特定事件類型註冊事件偵聽程式。
EventDispatcher
保護方法
 方法定義自
 Inherited
describeData(requiredFields:uint):Array
Called by the governing DataTransform to obtain a description of the data represented by this IChartElement.
AxisBase
事件
 事件 摘要 定義自
 Inherited[廣播事件] 當 Flash Player 或 AIR 應用程式取得作業系統焦點並成為作用中時傳送。EventDispatcher
 Inherited[廣播事件] 當 Flash Player 或 AIR 應用程式失去作業系統焦點並成為非作用中時傳送。EventDispatcher
屬性詳細資訊

baseline

屬性
baseline:Number  [唯讀]

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

The baseline position for the axis. Some series, such as ColumnSeries or AreaSeries, use this value to define the base of a filled region when no minimum value is specified.



實作
    public function get baseline():Number

categoryField

屬性 
categoryField:String

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

Specifies the field of the data provider containing the text for the labels. If this property is null, CategoryAxis assumes that the dataProvider contains an array of Strings.

預設值為 null。



實作
    public function get categoryField():String
    public function set categoryField(value:String):void

dataFunction

屬性 
dataFunction:Function

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

Specifies a method that returns the value that should be used as categoryValue for current item.If this property is set, the return value of the custom data function takes precedence over categoryField

The custom dataFunction has the following signature:

     function_name (axis:CategoryAxis, item:Object):Object { ... }
     
axis is the current axis that uses this dataFunction item is the item in the dataProvider that is considered. This function returns an object.

An example usage of a customized dataFunction is to return a value from a dataProvider that has items with nested fields



實作
    public function get dataFunction():Function
    public function set dataFunction(value:Function):void

範例
如何使用本範例
     public function myFunction(axis:CategoryAxis,item:Object):Object {
          return(item.Country.State);
     }     
     

dataProvider

屬性 
dataProvider:Object

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

Specifies the data source containing the label names. The dataProvider can be an Array of Strings, an Array of Objects, or any object that implements the IList or ICollectionView interface. If the dataProvider is an Array of Strings, ensure that the categoryField property is set to null. If the dataProvider is an Array of Objects, set the categoryField property to the name of the field that contains the label text.



實作
    public function get dataProvider():Object
    public function set dataProvider(value:Object):void

labelFunction

屬性 
labelFunction:Function

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

Specifies a function that defines the labels that are generated for each item in the CategoryAxis's dataProvider. If no labelFunction is provided, the axis labels default to the value of the category itself.

The labelFunction method for a CategoryAxis has the following signature:

      function function_name(categoryValue:Object, previousCategoryValue:Object, axis:CategoryAxis, categoryItem:Object):String { ... }
      

Where:

  • categoryValue is the value of the category to be represented.
  • previousCategoryValue is the value of the previous category on the axis.
  • axis is the CategoryAxis being rendered.
  • categoryItem is the item from the dataProvider that is being represented.

Flex displays the returned String as the axis label.

If the categoryField property is not set, the value will be the same as the categoryValue property.



實作
    public function get labelFunction():Function
    public function set labelFunction(value:Function):void

padding

屬性 
padding:Number

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

Specifies the padding added to either side of the axis when rendering data on the screen. Set to 0 to map the first category to the very beginning of the axis and the last category to the end. Set to 0.5 to leave padding of half the width of a category on the axis between the beginning of the axis and the first category and between the last category and the end of the axis.

This is useful for chart types that render beyond the bounds of the category, such as columns and bars. However, when used as the horizontalAxis in a LineChart or AreaChart, it is reset to 0.

預設值為 0.5。



實作
    public function get padding():Number
    public function set padding(value:Number):void

ticksBetweenLabels

屬性 
ticksBetweenLabels:Boolean

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

Specifies the location of major tick marks on the axis, relative to the category labels. If true, tick marks (and any associated grid lines) appear between the categories. If false, tick marks appear in the middle of the category, aligned with the label.



實作
    public function get ticksBetweenLabels():Boolean
    public function set ticksBetweenLabels(value:Boolean):void
建構函式詳細資料

CategoryAxis

()建構函式
public function CategoryAxis()

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

Constructor.

方法詳細資訊

filterCache

()方法
public function filterCache(cache:Array, field:String, filteredField:String):void

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

Filters a set of values of arbitrary type to a set of numbers that can be mapped.

參數

cache:Array — An Array of objects where converted values are read from and stored.
 
field:String — The field of the objects in the cache Array containing the pre-filtered values.
 
filteredField:String — The field of the objects in the cache Array where filtered values should be stored.

formatForScreen

()方法 
public function formatForScreen(value:Object):String

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

Formats values for display in DataTips. Returns a user-readable string.

參數

value:Object — The value to convert to a String.

傳回值
String — The text of the DataTip.

getLabelEstimate

()方法 
public function getLabelEstimate():AxisLabelSet

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

Determines the range to estimate what the axis labels should be. The axis almost immediately calls the getLabels() method to get the real values. The axis uses the estimated values to adjust chart margins, so any difference between the estimated labels and actual labels (returned from the getLabels() method) results in scaling the labels to fit.

An axis need only return the minimum and maximum labels when returning an estimate. If the label set is fairly static, without depending on the size of the axis being rendered on screen, an axis can return the entire label set from this function, and mark the estimate as accurate.

傳回值
AxisLabelSet — An Array of AxisLabel objects.

getLabels

()方法 
public function getLabels(minimumAxisLength:Number):AxisLabelSet

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

Gets the labels text that is rendered. When Flex calls this method, the axis has already determined the minimum length of the label.

參數

minimumAxisLength:Number — The minimum length of the axis, in pixels. The axis can be longer than this value, but not shorter.

傳回值
AxisLabelSet — An array of AxisLabel objects.

invertTransform

()方法 
public function invertTransform(value:Number):Object

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

Maps a position along the axis back to a numeric data value.

參數

value:Number — The bound of the axis. This parameter should be between 0 and 1, with 0 representing the minimum bound of the axis, and 1 the maximum.

傳回值
Object — An object containing the transformed value.

mapCache

()方法 
public function mapCache(cache:Array, field:String, convertedField:String, indexValues:Boolean = false):void

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

Converts a set of values of arbitrary type to a set of numbers that can be transformed into screen coordinates.

參數

cache:Array — An Array of objects where converted values are read from and stored.
 
field:String — The field of the objects in the cache Array containing the pre-converted values.
 
convertedField:String — The field of the objects in the cache Array where converted values should be stored.
 
indexValues:Boolean (default = false) — This parameter is true if the values being mapped are index values, and false if they are natural data values.

preferDropLabels

()方法 
public function preferDropLabels():Boolean

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

Determines how the axis handles overlapping labels. Typically, numeric ranges return true, while discrete value-based ranges do not. You can can override this property by setting it directly on the axis.

傳回值
Booleantrue if labels can be dropped without loss of data; otherwise, false.

reduceLabels

()方法 
public function reduceLabels(intervalStart:AxisLabel, intervalEnd:AxisLabel):AxisLabelSet

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

Invoked when an AxisRenderer is unable to cleanly render the labels without overlap, and would like the Axis object to reduce the set of labels. The method is passed the two labels that are overlapping.

參數

intervalStart:AxisLabel — The start of the interval where labels overlap.
 
intervalEnd:AxisLabel — The end of the interval where labels overlap.

傳回值
AxisLabelSet — A new label set that resolves the overlap by reducing the number of labels.

transformCache

()方法 
public function transformCache(cache:Array, field:String, convertedField:String):void

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

Maps a set of values from data space to screen space.

參數

cache:Array — An Array of objects where mapped values are read from and stored.
 
field:String — The field of the objects in the cache Array containing the pre-mapped values.
 
convertedField:String — The field of the objects in the cache Array where mapped values should be stored.

update

()方法 
public function update():void

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

Updates the chart. This can be called multiple times per frame.

HLOCChartExample.mxml
<?xml version="1.0"?>
<!-- Simple example to demonstrate the HLOCChart control. -->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:s="library://ns.adobe.com/flex/spark" 
    xmlns:mx="library://ns.adobe.com/flex/mx">
    <fx:Script>
        <![CDATA[          
        import mx.collections.ArrayCollection;

        [Bindable]
        private var stockDataAC:ArrayCollection = new ArrayCollection( [
            { Date: "25-Jul", Open: 40.55,  High: 40.75, Low: 40.24, Close:40.31},
            { Date: "26-Jul", Open: 40.15,  High: 40.78, Low: 39.97, Close:40.34},
            { Date: "27-Jul", Open: 40.38,  High: 40.66, Low: 40, Close:40.63},
            { Date: "28-Jul", Open: 40.49,  High: 40.99, Low: 40.3, Close:40.98},
            { Date: "29-Jul", Open: 40.13,  High: 40.4, Low: 39.65, Close:39.95},
            { Date: "1-Aug", Open: 39.00,  High: 39.50, Low: 38.7, Close:38.6}, 
            { Date: "2-Aug", Open: 38.68,  High: 39.34, Low: 37.75, Close:38.84}, 
            { Date: "3-Aug", Open: 38.76,  High: 38.76, Low: 38.03, Close:38.12}, 
            { Date: "4-Aug", Open: 37.98,  High: 37.98, Low: 36.56, Close:36.69},                       
            { Date: "5-Aug", Open: 36.61,  High: 37, Low: 36.48, Close:36.86} ]); 
        ]]>
    </fx:Script>

    <fx:Declarations>
        <!-- Define custom Stroke for the wick and ticks. -->
        <mx:SolidColorStroke id="s1" color="0x000000" weight="5" joints="bevel" caps="square"/>
    </fx:Declarations>

    <mx:Panel title="HLOCChart Control Example" height="100%" width="100%">
        <mx:HLOCChart id="hlocchart" height="100%" width="100%"
            paddingRight="5" paddingLeft="5" 
            showDataTips="true" dataProvider="{stockDataAC}">
            
            <mx:verticalAxis>
                <mx:LinearAxis id="vaxis" baseAtZero="false" title="Price"/>
            </mx:verticalAxis>

            <mx:horizontalAxis>
                <mx:CategoryAxis id="haxis" categoryField="Date" title="Date"/>
            </mx:horizontalAxis>

            <mx:horizontalAxisRenderers>
                <mx:AxisRenderer axis="{haxis}" canDropLabels="true"/>
            </mx:horizontalAxisRenderers>

            <mx:series>
                <mx:HLOCSeries 
                    openField="Open" 
                    highField="High" 
                    lowField="Low" 
                    closeField="Close"
                    stroke="{s1}"
                    openTickStroke="{s1}"
                    closeTickStroke="{s1}"
                    openTickLength="7"
                    closeTickLength="7"
                />
            </mx:series>
        </mx:HLOCChart>
    </mx:Panel>
</s:Application>




[ X ]為什麼顯示英文?
「ActionScript 3.0 參考」的內容是以英文顯示

並非所有「ActionScript 3.0 參考」的內容都翻譯為所有語言。當語言元素未翻譯時,就會以英文顯示。例如,ga.controls.HelpBox 類別並沒有翻譯為任何語言。因此在參考的繁體中文版本中,ga.controls.HelpBox 類別就會以英文顯示。