Thanks Tim, the hardcoded uniqueArr as dataprovider works but it doesnt work when i try to use it as a derived function as follows.
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:Script> <![CDATA[ import mx.controls.Alert; import mx.collections.ArrayCollection; import com.adobe.utils.ArrayUtil; [Bindable] public var someData:ArrayCollection = new ArrayCollection([ {editedEndDate:"01/01/2006", mpid:"GRAPES"}, {editedEndDate:"05/01/2007", mpid:"APPLE"}, {editedEndDate:"11/01/2009", mpid:"APPLE"}, {editedEndDate:"05/01/2008", mpid:"ORANGE"}, {editedEndDate:"05/01/2009", mpid:"MANGO"} ]); //[Bindable] //public var uniqueArr:Array = ["GRAPES","APPLE","ORANGE","MANGO"]; [Bindable] private var _uniqueArr:Array = new Array(); public function set uniqueArr(arry:Array):void{ _uniqueArr = arry; } public function get uniqueArr():Array{ _uniqueArr = new Array(); for each( var o:Object in mychart.dataProvider){ Alert.show(o.mpid.toString()); if(!ArrayUtil.arrayContainsValue(_uniqueArr,o.mpid)){ //Alert.show(o.mpid.toString()); _uniqueArr.push(o.mpid); } } return _uniqueArr; } ]]> </mx:Script> <mx:Panel title="DateTimeAxis" width="100%" height="100%"> <mx:PlotChart id="mychart" dataProvider="{someData}"> <mx:horizontalAxis><mx:DateTimeAxis dataUnits="days" /></mx:horizontalAxis> <mx:verticalAxis><mx:CategoryAxis dataProvider="{uniqueArr}" /></mx:verticalAxis> <mx:series><mx:PlotSeries yField="mpid" xField="editedEndDate" displayName="myData"/></mx:series> </mx:PlotChart> </mx:Panel> </mx:Application> -VM --- In [email protected], "Tim Hoff" <[EMAIL PROTECTED]> wrote: > > > Hi Vijay, > > This will get rid of your duplicate Apple. > > <mx:CategoryAxis dataProvider="{uniqueArr}"/> > > Although you have the uniqueArr hardcoded, you can derive that from the > data. > > -TH > > --- In [email protected], "Vijay Anand Mareddy" vam2@ > wrote: > > > > How do i make the CategoryAxis show only unique values > > > > In my example, I dont want the Apple to apear twice on the vertical > > axis. > > > > <?xml version="1.0" encoding="utf-8"?> > > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > > layout="absolute"> > > <mx:Script> > > <![CDATA[ > > import mx.controls.Alert; > > import mx.collections.ArrayCollection; > > import com.adobe.utils.ArrayUtil; > > > > [Bindable] > > public var someData:ArrayCollection = new ArrayCollection([ > > {editedEndDate:"01/01/2006", mpid:"GRAPES", modelId:1}, > > {editedEndDate:"05/01/2007", mpid:"APPLE", > > modelId:23}, > > {editedEndDate:"11/01/2009", mpid:"APPLE", modelId:160}, > > {editedEndDate:"05/01/2008", mpid:"ORANGE", > > modelId:4}, > > {editedEndDate:"05/01/2009", mpid:"MANGO", modelId:5} > > ]); > > > > [Bindable] > > public var uniqueArr:Array = ["GRAPES","APPLE","ORANGE","MANGO"]; > > > > private function uniqueMPIDFunc(axis:CategoryAxis, > > item:Object):Object { > > if(ArrayUtil.arrayContainsValue(ArrayCollection > > (axis.dataProvider).toArray(),item.mpid)){ > > Alert.show("exist:"+item.mpid+":"); > > return new Object(); > > } else { > > Alert.show("new:"+item.mpid+":"); > > return item.mpid; > > } > > > > } > > > > > > ]]> > > </mx:Script> > > > > <mx:Panel title="DateTimeAxis" width="100%" height="100%"> > > <mx:PlotChart id="mychart" dataProvider="{someData}" > > showDataTips="true"> > > <mx:horizontalAxis> > > <mx:DateTimeAxis dataUnits="days" /> > > </mx:horizontalAxis> > > <mx:verticalAxis> > > <mx:CategoryAxis > > dataFunction="uniqueMPIDFunc"/> > > </mx:verticalAxis> > > <mx:series> > > <mx:PlotSeries yField="mpid" > > xField="editedEndDate" displayName="myData"/> > > </mx:series> > > </mx:PlotChart> > > </mx:Panel> > > > > </mx:Application> > > >

