Use these methods to cycle through the data points in a ColumnChart control. : Column Chart Data « Chart « Flex






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.
           

<!--
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/SimpleCycle.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    creationComplete="initApp()">
    <mx:Script>
        
        import mx.collections.ArrayCollection;
        import mx.charts.chartClasses.ChartBase;
        import mx.charts.ChartItem;
        import mx.charts.series.items.ColumnSeriesItem;
        [Bindable]
        private var expensesAC:ArrayCollection = new ArrayCollection( [
            { Month: "Jan", Expenses: 1500, Amount: 450, Profit: 2000 },
            { Month: "Feb", Expenses: 200, Amount: 600, Profit: 1000 },
            { Month: "Mar", Expenses: 500, Amount: 300, Profit: 1500 },
            { Month: "Apr", Expenses: 1200, Amount: 900, Profit: 1800 },
            { Month: "May", Expenses: 575, Amount: 500, Profit: 2400 } ]);
        private function initApp():void {
            // Select the first item on start up.
            series1.selectedIndex = 0;
        }
        private function getNext(e:Event, dir:*):void {
            var curItem:ChartItem = series1.selectedItem;
            var newItem:ChartItem = myChart.getNextItem(dir);
            applyNewItem(newItem);
        }
        private function getPrev(e:Event, dir:*):void {
            var curItem:ChartItem = series1.selectedItem;
            var newItem:ChartItem = myChart.getPreviousItem(dir);
            applyNewItem(newItem);
        }
        private function getFirst(e:Event, dir:*):void {
            var newItem:ChartItem = myChart.getFirstItem(dir);
            applyNewItem(newItem);
        }
        private function getLast(e:Event, dir:*):void {
            var newItem:ChartItem = myChart.getLastItem(dir);
            applyNewItem(newItem);
        }
        private function applyNewItem(n:ChartItem):void {
            series1.selectedItem = n;
        }
      
    </mx:Script>
    <mx:Panel height="100%" width="100%">
        <mx:ColumnChart id="myChart" height="207" width="350"
            showDataTips="true" dataProvider="{expensesAC}"
            selectionMode="single">
            <mx:series>
                <mx:ColumnSeries id="series1" yField="Expenses"
                    displayName="Expenses" selectable="true" />
            </mx:series>
            <mx:horizontalAxis>
                <mx:CategoryAxis categoryField="Month" />
            </mx:horizontalAxis>
        </mx:ColumnChart>
        <mx:HBox>
            <mx:Label id="label0" text="Value: " />
            <mx:Label id="label1" />
        </mx:HBox>
        <mx:Legend dataProvider="{myChart}" width="200" />
        <mx:HBox>
            <mx:Button label="|&lt;"
                click="getFirst(event, ChartBase.HORIZONTAL);" />
            <mx:Button label="&lt;"
                click="getPrev(event, ChartBase.HORIZONTAL);" />
            <mx:Button label="&gt;"
                click="getNext(event, ChartBase.HORIZONTAL);" />
            <mx:Button label="&gt;|"
                click="getLast(event, ChartBase.HORIZONTAL);" />
        </mx:HBox>
    </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.Add a CartesianDataCanvas as an annotation element to the ColumnChart control.Add a CartesianDataCanvas as an annotation element to the ColumnChart control.
5.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.
6.Define a data provider on the chart controlDefine a data provider on the chart control
7.Compare yField in data provider when it fills each chart itemCompare yField in data provider when it fills each chart item
8.Data Tip Function for chartData Tip Function for chart