Set LinearAxis, and formats the values to include a dollar sign and a thousands separator. : Column Chart Axis « Chart « Flex






Set LinearAxis, and formats the values to include a dollar sign and a thousands separator.

Set LinearAxis, and formats the values to include a dollar sign and a thousands separator.
            

<!--
Code from Flex 4 Documentation "Using Adobe Flex 4".

This user guide is licensed for use under the terms of the Creative Commons Attribution 
Non-Commercial 3.0 License. 

This License allows users to copy, distribute, and transmit the user guide for noncommercial 
purposes only so long as 
  (1) proper attribution to Adobe is given as the owner of the user guide; and 
  (2) any reuse or distribution of the user guide contains a notice that use of the user guide is governed by these terms. 
The best way to provide notice is to include the following link. 
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/

-->
<!-- charts/CustomLabelFunction.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script>
        import mx.charts.*;
        import mx.collections.ArrayCollection;
        [Bindable]
        public var expenses:ArrayCollection = new ArrayCollection([
            {Month: "Jan", Income: 2000, Expenses: 1500},
            {Month: "Feb", Income: 1000, Expenses: 200},
            {Month: "Mar", Income: 1500, Expenses: 500}
            ]);
        // This method customizes the values of the axis labels.
        // This signature (with 4 arguments) is for a CategoryAxis.
        public function defineLabel(cat:Object,pcat:Object,ax:CategoryAxis,labelItem:Object):String{
            // Show contents of the labelItem:
            for (var s:String in labelItem) {
            trace(s + ":" + labelItem[s]);
            }
            // Return the customized categoryField value:
            return cat + " '07";
            // Note that if you did not specify a categoryField,
            // cat would refer to the entire object and not the
            // value of a single field. You could then access
            // fields by using cat.field_name.
       }
            // For a NumericAxis, you do not use the labelItem argument.
            // This example uses a NumberFormatter to add a thousands
            // separator.
        public function defineVerticalLabel(cat:Object,pcat:Object,ax:LinearAxis):String{
            return "$" + numForm.format(cat);
        
        }
      </mx:Script>
    <mx:NumberFormatter id="numForm" useThousandsSeparator="true" />
    <mx:Panel>
        <mx:ColumnChart id="column" dataProvider="{expenses}">
            <mx:horizontalAxis>
                <mx:CategoryAxis categoryField="Month" title="Expenses"
                    labelFunction="defineLabel" />
            </mx:horizontalAxis>
            <mx:verticalAxis>
                <mx:LinearAxis title="Income" minimum="0" maximum="2500"
                    labelFunction="defineVerticalLabel" />
            </mx:verticalAxis>
            <mx:series>
                <mx:ColumnSeries xField="Month" yField="Income"
                    displayName="Income" />
                <mx:ColumnSeries xField="Month" yField="Expenses"
                    displayName="Expenses" />
            </mx:series>
        </mx:ColumnChart>
    </mx:Panel>
</mx:Application>

   
    
    
    
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.horizontal Axis Renderer for ColumnCharthorizontal Axis Renderer for ColumnChart
2.Axis Renderer for ColumnChartAxis Renderer for ColumnChart
3.vertical Axis Renderer for ColumnChartvertical Axis Renderer for ColumnChart
4.Create a ColumnChart control with the default axis locations (bottom and left).Create a ColumnChart control with the default axis locations (bottom and left).
5.Column Chart Axis LabelColumn Chart Axis Label
6.Set Axis label for Column chartSet Axis label for Column chart
7.Customize horizontalAxisRenderer and AxisRendererCustomize horizontalAxisRenderer and AxisRenderer
8.Customize axisStrokeCustomize axisStroke
9.use the secondHorizontalAxisRenderer and secondVerticalAxisRenderer properties to control the appearance of the secondary axisuse the secondHorizontalAxisRenderer and secondVerticalAxisRenderer properties to control the appearance of the secondary axis
10.The following example removes tick marks from the horizontal axis:The following example removes tick marks from the horizontal axis:
11.Date Time Axis RangeDate Time Axis Range
12.Adding axis titlesAdding axis titles
13.Create two functions that access complex data for both the axis and the seriesCreate two functions that access complex data for both the axis and the series
14.Remove tick marks from the horizontal axisRemove tick marks from the horizontal axis