1. Narrative description of the problem
A set of radio button, there are weeks and months, the choice of "Week", the histogram is displayed in the horizontal axis of the week, the vertical axis shows the number of people; Select "Month", histogram horizontal display of the month, the ordinate shows the ratio.
2. Demo Example
<?XML version= "1.0" encoding= "Utf-8"? ><s:application xmlns:fx= "http://ns.adobe.com/mxml/2009" xmlns:s= "library ://ns.adobe.com/flex/spark "xmlns:mx=" library://ns.adobe.com/flex/mx "width=" 100% "height=" 100% "CreationComplete = "Inithandler (event)" fontfamily= "Microsoft Jas Black" fontsize= "><s:layout><s:BasicLayout/></s:layout>" <fx:script><! [Cdata[import mx.collections.arraycollection;import Mx.controls.alert;import Mx.events.flexevent;import Mx.events.ItemClickEvent; [bindable]//graph Data Binding private var chartarray:arraycollection = new ArrayCollection ([{week: "Monday", Month: "January", Person: "8989 ", Rate:"},{week: "Tuesday", Month: "February", Person: "5675", Rate: "},{week": "Wednesday", Month: "March", Person: "7234", Rate: "12"},{ Week: "Thursday", Month: "April", Person: "3456", Rate: "},{week": "Friday", Month: "May", Person: "6355", Rate: "},{week", "Saturday", Month: ' June ', Person: ' 4356 ', Rate: '},{week ': ' Sunday ', Month: ' July ', Person: ' 9087 ', Rate: ' 87 '}],/** * initialization function */protected function Inithandler (event:flexevent): void{}/** * Query buTton functions */protected function Search_clickhandler (event:mouseevent): void{}/** * radio button toggle function */protected functions Radiogroup_itemclickhandler (event:itemclickevent): Void{if (event.currenttarget.selectedvalue== "Week") { Datax.categoryfield = "Week";d atax.displayname = "Week";d Ate.xfield = "Week";d Ate.yfield = "Person";d Ate.displayname = "Number of people" ;} else if (event.currenttarget.selectedvalue== "month") {Datax.categoryfield = ' month ';d atax.displayname = "month";d Ate.xfield = " Month ";d Ate.yfield =" rate ";d Ate.displayname =" ratio ";}]] ></fx:script><fx:declarations><s:radiobuttongroup id= "Radiogroup" itemClick= "Radiogroup_ Itemclickhandler (Event) "/></fx:declarations><s:vgroup width=" 100% "height=" 100% "paddingBottom=" 10 " Paddingleft= "Ten" paddingright= "paddingtop=" horizontalalign= "center" ><s:hgroup width= "100%" height= "30 "Paddingleft=" verticalalign= "Middle" ><s:label text= "date type:"/><s:label width= "/><s: RadioButton label= "Week" groupname= "Radiogroup" value= "Week" Selected= "true"/><s:label width= "/><s:radiobutton label=" month "groupname=" Radiogroup "value=" Month "/> <s:label width= "/><s:button label=" query "id=" search "click=" Search_clickhandler (Event) "/></S: Hgroup><mx:columnchart id= "column" dataprovider= "{Chartarray}" width= "100%" height= "80%" columnwidthratio= " 0.4 "showdatatips=" true "><mx:horizontalaxis><mx:categoryaxis id=" datax "categoryfield=" Week " Displayname= "Week"/></mx:horizontalaxis><mx:series><mx:columnseries displayName= "number" id= "date" Xfield= "Week" yfield= "person"/></mx:series></mx:columnchart><mx:legend dataprovider= "{column}" /></s:vgroup></s:application>
3. Example Results
(1) When initializing
(2) Select "Month"
watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvew91mjnoywk0nq==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center "width=" 710 "height=" 383 "border=" 1 ">
Copyright notice: This article Bo Master original article. Blog, not reproduced without consent.
Flex Toggles histogram horizontal and descriptive notes using the radio button