Compare yField in data provider when it fills each chart item : Column Chart Data « Chart « Flex






Compare yField in data provider when it fills each chart item

Compare yField in data provider when it fills each chart item
           
<!--
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/SimpleFillFunction.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script>
        
        import mx.graphics.IFill;
        import mx.graphics.SolidColor;
        import mx.collections.ArrayCollection;
        import mx.charts.ChartItem;
        import mx.charts.series.items.ColumnSeriesItem;
        [Bindable]
        public var sales:ArrayCollection = new ArrayCollection([
            { Name:"Reiner", CurrentAmount:69000 },
            { Name:"Klaus", CurrentAmount:38000 },
            { Name:"Alan", CurrentAmount:44000 },
            { Name:"Wolfgang", CurrentAmount:33000 },
            { Name:"Francis", CurrentAmount:20000 },
            { Name:"Klaus-Jurgen", CurrentAmount:55000 },
            { Name:"Martin", CurrentAmount:70000 },
            { Name:"Mac", CurrentAmount:35000 },
            { Name:"Friedemann", CurrentAmount:38000 },
            { Name:"Bruno", CurrentAmount:40000 }
            ]);
        private function myFillFunction(element:ChartItem, index:Number):IFill
        {
            var c:SolidColor = new SolidColor(0x00CC00);
            var item:ColumnSeriesItem = ColumnSeriesItem(element);
            var sales:Number = Number(item.yValue);
            if (sales >= 50000) {
                return c;
            } else {
                // They have not met their goal.
                c.color = 0xFF0000;
            }
            return c;
        }
      
    </mx:Script>
    <mx:Panel title="Using a custom fillFunction in a Column Chart">
        <mx:ColumnChart id="myChart" dataProvider="{sales}"
            showDataTips="true">
            <mx:horizontalAxis>
                <mx:CategoryAxis title="Sales Person" categoryField="Name" />
            </mx:horizontalAxis>
            <mx:verticalAxis>
                <mx:LinearAxis title="Sales (in $USD)" />
            </mx:verticalAxis>
            <mx:series>
                <mx:ColumnSeries id="currSalesSeries" xField="Name"
                    yField="CurrentAmount" fillFunction="myFillFunction"
                    displayName="Current Sales" />
            </mx:series>
        </mx:ColumnChart>
        <mx:Legend>
            <mx:LegendItem label="More than $50K" fontWeight="bold">
                <mx:fill>
                    <mx:SolidColor color="0x00FF00" />
                </mx:fill>
                <mx:stroke>
                    <mx:Stroke color="0x000000" weight="1" />
                </mx:stroke>
            </mx:LegendItem>
            <mx:LegendItem label="Less than $50K" fontWeight="bold">
                <mx:fill>
                    <mx:SolidColor color="0xFF0000" />
                </mx:fill>
                <mx:stroke>
                    <mx:Stroke color="0x000000" weight="1" />
                </mx:stroke>
            </mx:LegendItem>
        </mx:Legend>
    </mx:Panel>
</mx:Application>

   
    
    
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Using ArrayCollection Of Verbose MXML Objects for ColumnChartUsing ArrayCollection Of Verbose MXML Objects for ColumnChart
2.creates data labels for each of the columns in the ColumnChart control:creates data labels for each of the columns in the ColumnChart control:
3.Set the value of a ColumnChart control's dataTipMode property to multiple:Set the value of a ColumnChart control's dataTipMode property to multiple:
4.Use these methods to cycle through the data points in a ColumnChart control.Use these methods to cycle through the data points in a ColumnChart control.
5.Add a CartesianDataCanvas as an annotation element to the ColumnChart control.Add a CartesianDataCanvas as an annotation element to the ColumnChart control.
6.Use the addDataChild() method to add children to the data canvas. It adds labels to each of the columns that you select in the ColumnChart control.Use the addDataChild() method to add children to the data canvas. It adds labels to each of the columns that you select in the ColumnChart control.
7.Define a data provider on the chart controlDefine a data provider on the chart control
8.Data Tip Function for chartData Tip Function for chart