Packagecom.amcharts.axes
Classpublic class CategoryAxis
InheritanceCategoryAxis Inheritance AxisBase Inheritance mx.core.UIComponent

CategoryAxis is the class which displays category axis for the Serial Chart. The chart can have only one category axis. If you do not add category axis to the Serial chart, it will be created automatically.

View the examples.



Public Properties
 PropertyDefined by
  autoTruncate : Boolean
Specifies if category labels should be truncated if they don't fit.
CategoryAxis
  dateFormats : Array
Array of date format objects.
CategoryAxis
  equalSpacing : Boolean
In case your category axis values are Date objects and parseDates is set to true, the chart will parse dates and will place your data points at irregular intervals.
CategoryAxis
  firstDayOfWeek : Number
Defines on which day week starts.
CategoryAxis
  gridPosition : String
Specifies if a grid line is placed on the center of a cell or on the beginning of a cell.
CategoryAxis
 Inheritedguides : Array
The array of guides belonging to this axis.
AxisBase
 InheritedignoreAxisWidth : Boolean
If autoMargins property of a chart is set to true but you don't want this axis to be measured when calculating margin width, set ignoreAxisWidth to true
AxisBase
 Inheritedinside : Boolean
Whether values should be placed inside or outside plot area.
AxisBase
 InheritedlabelFunction : Function
Label function.
AxisBase
 InheritedmaxLabelLength : Number
Maximum length (number of symbols) of a label.
AxisBase
 InheritedmaxLabelWidth : Number
returns max width of values
AxisBase
  minPeriod : String
Specifies the shortest period of your data.
CategoryAxis
 Inheritedoffset : Number
The distance of the axis to the plot area, in pixels.
AxisBase
  parseDates : Boolean
In case your category axis values are Date objects, set this to true.
CategoryAxis
 Inheritedposition : String
Position of the axis.
AxisBase
  startOnAxis : Boolean
Specifies whether the graph should start on axis or not.
CategoryAxis
 Inheritedtitle : String
Axis title will be displayed next to axis.
AxisBase
 InheritedtitleAlignment : String
Alignment of axis title.
AxisBase
 InheritedtitleTextColor : Number
Text color of axis title Will use default axis color style value if not set
AxisBase
 InheritedtitleTextSize : Number
Text size of axis title
AxisBase
 InheritedvalueClickHandler : Function
Method which will be called when user clicks on the axis label
AxisBase
  wrapLabels : Boolean
Specifies if category labels should be wrapped if they don't fit Doesn't work if labels are rotated, or category axis is vertical.
CategoryAxis
Public Methods
 MethodDefined by
  
Constructor.
CategoryAxis
 Inherited
Adds guide to the axis
AxisBase
  
categoryToCoordinate(category:String):Number
returns coordinate of a category.
CategoryAxis
  
coordinateToDate(coordinate:Number):Date
Returns Date of the coordinate, in case parseDates is set to true.
CategoryAxis
  
dateToCoordinate(date:Date):Number
Returns coordinate of the date, in case parseDates is set to true.
CategoryAxis
  
formatDate(date:Date):String
Formats Date object into String using date format of the minPeriod.
CategoryAxis
  
getDateFormat(period:String):String
Returns date format of a period.
CategoryAxis
 Inherited
removeGuide(guide:Guide):void
Removes guide from the axis
AxisBase
  
setDateFormat(period:String, format:String):void
Specifies the date format of the period.
CategoryAxis
Events
 EventSummaryDefined by
 Inherited Dispatched every time when axis is rebuild.AxisBase
Styles
 StyleDescriptionDefined by
 Inherited Type: Boolean   CSS Inheritance: no
Specifies whether number of gridCount is specified automatically, acoarding to the axis size.
AxisBase
 Inherited Type: Number   CSS Inheritance: no
Axis opacity.
AxisBase
 Inherited Type: uint   Format: Color   CSS Inheritance: no
Axis color.
AxisBase
 Inherited Type: Number   CSS Inheritance: no
Thickness of the axis.
AxisBase
 Inherited Type: Number   CSS Inheritance: no
Specifies the distance from Radar axis end to the axis title
AxisBase
 Inherited Type: uint   Format: Color   CSS Inheritance: yes
Color of text in the component, including the component label.
AxisBase
 Inherited Type: Number   CSS Inheritance: no
length of a dash.
AxisBase
 Inherited Type: uint   Format: Color   CSS Inheritance: yes
Color of text in the component if it is disabled.
AxisBase
 Inherited Type: Number   CSS Inheritance: no
Fill opacity.
AxisBase
 Inherited Type: Number   CSS Inheritance: no
Fill color.
AxisBase
 Inherited Type: String   CSS Inheritance: yes
Sets the antiAliasType property of internal TextFields.
AxisBase
 Inherited Type: String   CSS Inheritance: yes
Name of the font to use.
AxisBase
 Inherited Type: String   CSS Inheritance: yes
Sets the gridFitType property of internal TextFields that represent text in Flex controls.
AxisBase
 Inherited Type: Number   CSS Inheritance: yes
Sets the sharpness property of internal TextFields that represent text in Flex controls.
AxisBase
 Inherited Type: Number   Format: Length   CSS Inheritance: yes
Height of the text, in pixels.
AxisBase
 Inherited Type: String   CSS Inheritance: yes
Determines whether the text is italic font.
AxisBase
 Inherited Type: Number   CSS Inheritance: yes
Sets the thickness property of internal TextFields that represent text in Flex controls.
AxisBase
 Inherited Type: String   CSS Inheritance: yes
Determines whether the text is boldface.
AxisBase
 Inherited Type: Number   CSS Inheritance: no
Opacity of grid lines.
AxisBase
 Inherited Type: uint   Format: Color   CSS Inheritance: no
Color of grid lines.
AxisBase
 Inherited Type: Number   CSS Inheritance: no
Number of grid lines.
AxisBase
 Inherited Type: Number   CSS Inheritance: no
Thickness of grid lines.
AxisBase
 Inherited Type: String   CSS Inheritance: no
Grid type, used by Radar chart only.
AxisBase
 Inherited Type: Boolean   CSS Inheritance: yes
A Boolean value that indicates whether kerning is enabled (true) or disabled (false).
AxisBase
 Inherited Type: Number   CSS Inheritance: yes
Label background opacity.
AxisBase
 Inherited Type: Number   Format: Color   CSS Inheritance: yes
Label background color.
AxisBase
 Inherited Type: Number   CSS Inheritance: no
Frequency at which labels should be placed.
AxisBase
 Inherited Type: Number   CSS Inheritance: no
Rotation angle of a label.
AxisBase
 Inherited Type: Boolean   CSS Inheritance: no
Specifies whether axis displays category axis' labels and value axis' values
AxisBase
 Inherited Type: Number   CSS Inheritance: yes
The number of additional pixels to appear between each character.
AxisBase
 Inherited Type: Boolean   CSS Inheritance: no
Specifies whether Radar chart displays categories at the end of the axis
AxisBase
 Inherited Type: Boolean   CSS Inheritance: no
Whether to show first axis label or not.
AxisBase
 Inherited Type: Boolean   CSS Inheritance: no
Whether to show last axis label or not.
AxisBase
 Inherited Type: String   CSS Inheritance: yes
Alignment of text within a container.
AxisBase
 Inherited Type: String   CSS Inheritance: yes
Determines whether the text is underlined.
AxisBase
 Inherited Type: Number   Format: Length   CSS Inheritance: yes
Offset of first line of text from the left side of the container, in pixels.
AxisBase
 Inherited Type: Number   CSS Inheritance: no
Tick length.
AxisBase
 Inherited Type: uint   Format: Color   CSS Inheritance: no
value roll over color (only works if valueClickHandler is set)
AxisBase
Property detail
autoTruncateproperty
autoTruncate:Boolean  [read-write]

Specifies if category labels should be truncated if they don't fit. Doesn't work if labels are rotated, or category axis is vertical.

The default value is false.

Implementation
    public function get autoTruncate():Boolean
    public function set autoTruncate(value:Boolean):void
dateFormatsproperty 
dateFormats:Array  [read-write]

Array of date format objects. Date format object must have "period" and "format" items. Available periods are: fff - millisecond, ss - second, mm - minute, hh - hour, DD - date, MM - month, YYYY - year. format can contain any string supported by mx.formatters.DateFormatter class. For example: {period:"DD", format:"MMM DD"}

The default value is [{period:'fff',format:'JJ:NN:SS'},{period:'ss',format:'JJ:NN:SS'},{period:'mm',format:'JJ:NN'},{period:'hh',format:'JJ:NN'},{period:'DD',format:'MMM DD'},{period:'MM',format:'MMM'},{period:'YYYY',format:'YYYY'}].

Implementation
    public function get dateFormats():Array
    public function set dateFormats(value:Array):void
equalSpacingproperty 
equalSpacing:Boolean  [read-write]

In case your category axis values are Date objects and parseDates is set to true, the chart will parse dates and will place your data points at irregular intervals. However if you want dates to be parsed (displayed on the axis, baloons, etc), but data points to be placed at equal intervals (omiting dates with no data), set equalSpacing to true.

The default value is false.

Implementation
    public function get equalSpacing():Boolean
    public function set equalSpacing(value:Boolean):void
firstDayOfWeekproperty 
firstDayOfWeek:Number  [read-write]

Defines on which day week starts. 0 - Sunday, 1 - Monday...

The default value is 1 (Monday).

Implementation
    public function get firstDayOfWeek():Number
    public function set firstDayOfWeek(value:Number):void
gridPositionproperty 
gridPosition:String  [read-write]

Specifies if a grid line is placed on the center of a cell or on the beginning of a cell. Possible values are: start and middle This setting doesn't work if parseDates is set to true

The default value is middle.

Implementation
    public function get gridPosition():String
    public function set gridPosition(value:String):void
minPeriodproperty 
minPeriod:String  [read-write]

Specifies the shortest period of your data. This should be set only if parseDates is set to "true".

  • fff - millisecond
  • ss - second
  • mm - minute
  • hh - hour
  • DD - day
  • MM - month
  • YYYY - year
  • The default value is DD.

    Implementation
        public function get minPeriod():String
        public function set minPeriod(value:String):void
    parseDatesproperty 
    parseDates:Boolean  [read-write]

    In case your category axis values are Date objects, set this to true. In this case the chart will parse dates and will place your data points at irregular intervals.

    The default value is false.

    Implementation
        public function get parseDates():Boolean
        public function set parseDates(value:Boolean):void
    startOnAxisproperty 
    startOnAxis:Boolean  [read-write]

    Specifies whether the graph should start on axis or not. In case you display columns, it is recommended to set this to false. If parseDates is set to true, startOnAxis will allways be "false", unless equalSpacing is set to true.

    The default value is false.

    Implementation
        public function get startOnAxis():Boolean
        public function set startOnAxis(value:Boolean):void
    wrapLabelsproperty 
    wrapLabels:Boolean  [read-write]

    Specifies if category labels should be wrapped if they don't fit Doesn't work if labels are rotated, or category axis is vertical. Only works if parseDates is false.

    The default value is false.

    Implementation
        public function get wrapLabels():Boolean
        public function set wrapLabels(value:Boolean):void
    Constructor detail
    CategoryAxis()constructor
    public function CategoryAxis()

    Constructor.

    Method detail
    categoryToCoordinate()method
    public function categoryToCoordinate(category:String):Number

    returns coordinate of a category. Works only if parseDates is false. If parseDates is true, use dateToCoordinate method.

    Parameters
    category:String

    Returns
    Number
    coordinateToDate()method 
    public function coordinateToDate(coordinate:Number):Date

    Returns Date of the coordinate, in case parseDates is set to true. Example: myCategoryAxis.coordinateToDate(myCategoryAxis.mouseX);

    Parameters
    coordinate:Number

    Returns
    Date
    dateToCoordinate()method 
    public function dateToCoordinate(date:Date):Number

    Returns coordinate of the date, in case parseDates is set to true. if parseDates is false, use categoryToCoordinate method.

    Parameters
    date:Date

    Returns
    Number
    formatDate()method 
    public function formatDate(date:Date):String

    Formats Date object into String using date format of the minPeriod.

    Parameters
    date:Date

    Returns
    String
    getDateFormat()method 
    public function getDateFormat(period:String):String

    Returns date format of a period.

    Parameters
    period:String

    Returns
    String
    setDateFormat()method 
    public function setDateFormat(period:String, format:String):void

    Specifies the date format of the period.

    Parameters
    period:String — valid values are: ff,ss,mm,hh,DD,MM,YYYY
     
    format:String — can contain strings supported by mx.formatters.DateFormatter:
    Examples
    dateBasedCategoryAxis
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                    xmlns:amcharts="http://www.amcharts.com/com_internal"
                    layout="absolute"
                    backgroundColor="#FFFFFF"
                    width="100%"
                    height="100%" viewSourceURL="srcview/index.html">
        
        <mx:Script>
            <![CDATA[
                import mx.collections.ArrayCollection;
                
                [Bindable]
                private var chartData:ArrayCollection = new ArrayCollection([
                    {date:new Date(2009,10,2),value:11,value2:2},
                    {date:new Date(2009,10,3),value:15,value2:3},
                    {date:new Date(2009,10,4),value:13,value2:2},
                    {date:new Date(2009,10,5),value:17,value2:1},
                    {date:new Date(2009,10,6),value:15,value2:1},
                    {date:new Date(2009,10,9),value:19,value2:2},
                    {date:new Date(2009,10,10),value:21,value2:2},
                    {date:new Date(2009,10,11),value:20,value2:2},
                    {date:new Date(2009,10,12),value:20,value2:3},
                    {date:new Date(2009,10,13),value:19,value2:4},
                    {date:new Date(2009,10,16),value:25,value2:3},
                    {date:new Date(2009,10,17),value:24,value2:2},
                    {date:new Date(2009,10,18),value:26,value2:2},
                    {date:new Date(2009,10,19),value:27,value2:1},
                    {date:new Date(2009,10,20),value:25,value2:3},
                    {date:new Date(2009,10,23),value:29,value2:4},
                    {date:new Date(2009,10,24),value:28,value2:2},
                    {date:new Date(2009,10,25),value:30,value2:4},
                    {date:new Date(2009,10,26),value:32,value2:3},
                    {date:new Date(2009,10,27),value:33,value2:3},
                    {date:new Date(2009,10,30),value:31,value2:3},
                    {date:new Date(2009,11,1),value:30,value2:2},
                    {date:new Date(2009,11,2),value:29,value2:1},
                    {date:new Date(2009,11,3),value:27,value2:1},
                    {date:new Date(2009,11,4),value:26,value2:1}
                ]);
                
                private function zoom():void{
                    var count:Number = chartData.length;
                    chart.zoomToIndexes(count - 10, count - 1);
                }
            ]]>
        </mx:Script>
        
        <amcharts:AmSerialChart 
            dataUpdated="{zoom()}"
            id="chart"
            width="100%"
            height="100%"
            dataProvider="{chartData}"
            categoryField="date"
            angle="30"
            depth3D="20">
            
            <amcharts:graphs>
                <amcharts:AmGraph id="g1" valueField="value" type="column" fillAlphas="[1]" lineColor="#D8E63C"/>                        
                <amcharts:AmGraph id="g2" valueField="value2" type="column" fillAlphas="[1]" lineColor="#E1CE4F"/>                        
            </amcharts:graphs>
            
            <!-- It is very important to tell the category axis if it's values are date based or not.
            In case yes, set parseDates to true. You should also set the minimum period of your data.
            For example, if you have hourly data, set minPeriod to "hh". -->
            <amcharts:categoryAxis>
                <amcharts:CategoryAxis parseDates="true" minPeriod="DD"/>
            </amcharts:categoryAxis>
            
            <amcharts:valueAxes>
                <amcharts:ValueAxis stackType="regular"/>
            </amcharts:valueAxes>
            
            <amcharts:chartCursor>
                <amcharts:ChartCursor/>                        
            </amcharts:chartCursor>
            
            <amcharts:chartScrollbar>
                <amcharts:ChartScrollbar graph="{g1}"/>                        
            </amcharts:chartScrollbar>
    
        </amcharts:AmSerialChart>
        
    </mx:Application>
    regularCategoryAxis
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                    xmlns:amcharts="http://www.amcharts.com/com_internal"
                    layout="absolute"
                    backgroundColor="#FFFFFF"
                    width="100%"
                    height="100%" viewSourceURL="srcview/index.html">
        <mx:Script>
            <![CDATA[
                import mx.collections.ArrayCollection;
                
                [Bindable]
                private var shadow:DropShadowFilter = new DropShadowFilter(2,45,0,0.5);
                
                [Bindable]
                private var chartData:ArrayCollection = new ArrayCollection([
                    {year:2005,income:23.5,expences:18.1},
                    {year:2006,income:26.2,expences:22.8},
                    {year:2007,income:30.1,expences:23.9},
                    {year:2008,income:29.5,expences:25.1},
                    {year:2009,income:24.6,expences:25.0}
                ]);            
            ]]>
        </mx:Script>
        
        <mx:VBox width="100%" height="100%">    
            <amcharts:AmSerialChart
                id="chart"
                width="100%"
                height="100%"
                dataProvider="{chartData}"
                categoryField="year"
                startDuration="1"
                rotate="true">
                
                <amcharts:graphs>
                    <amcharts:AmGraph title="Income" valueField="income" type="column" lineAlpha="0" fillColors="[#ADD981]" fillAlphas="[1]"/>                        
                    <amcharts:AmGraph title="Expences" valueField="expences" type="line" lineThickness="2" bullet="round" filters="{[shadow]}"/>                        
                </amcharts:graphs>
                <amcharts:categoryAxis>
                    <amcharts:CategoryAxis gridPosition="start" dashLength="5" fillAlpha="0.1" fillColor="#000000"/>                            
                </amcharts:categoryAxis>
            </amcharts:AmSerialChart>
            <amcharts:AmLegend marginLeft="50" dataProvider="{chart}" textClickEnabled="false"/>                     
        </mx:VBox>
    </mx:Application>