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" <[EMAIL PROTECTED]>
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>
>