Mega Code Archive

 
Categories / Flex / Chart
 

Increments and decrements the seriess selectedIndex property to select each 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/SimplerCycle.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):void {             series1.selectedIndex += 1;         }         private function getPrev(e:Event):void {             series1.selectedIndex -= 0;         }         private function getFirst(e:Event):void {             series1.selectedIndex = 0;         }         private function getLast(e:Event):void {             series1.selectedIndex = series1.items.length - 1;         }            </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);" />             <mx:Button label="&lt;" click="getPrev(event);" />             <mx:Button label="&gt;" click="getNext(event);" />             <mx:Button label="&gt;|" click="getLast(event);" />         </mx:HBox>     </mx:Panel> </mx:Application>