4 Replies Latest reply on Nov 4, 2010 11:55 AM by harry_lai84

    Flex Date Time Axis Not showing Correct Values

    V Katkar

      <?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/halo" width="700" height="500">

       

      <fx:Declarations>

      <!-- Place non-visual elements (e.g., services, value objects) here -->

       

      </fx:Declarations>

      <fx:Script>

      <![CDATA[

       

      import mx.collections.ArrayCollection;

       

      [Bindable]

      public var stockDataAC:ArrayCollection = new ArrayCollection( [

      {date: "2005, 7, 27", close: 41.71},

      {date: "2005, 7, 28", close: 42.21},

      {date: "2005, 3, 29", close: 42.11},

      {date: "2005, 1, 1", close: 42.71},

      {date: "2005, 10, 2", close: 42.99},

      {date: "2005, 9, 3", close: 44} ]);

       

      public function myParseFunction(s:String):Date {

      // Get an array of Strings from the comma-separated String passed in.

      var a:Array = s.split(",");

      // Create the new Date object. Subtract one from the month property.

      // The month property is zero-based in the Date constructor.

      var newDate:Date = new Date(a[0],a[1]-1,a[2]);

      return newDate;

      }

      ]]>

      </fx:Script>

       

      <mx:Panel title="DateTimeAxis Example" height="100%" width="100%">

       

      <mx:LineChart id="mychart" height="100%" width="100%"

        paddingRight="5" paddingLeft="5"

        showDataTips="true" dataProvider="{stockDataAC}">

       

      <mx:horizontalAxis>

      <mx:DateTimeAxis dataUnits="days" parseFunction="myParseFunction"/>

      </mx:horizontalAxis>

       

      <mx:verticalAxis>

      <mx:LinearAxis baseAtZero="false" />

      </mx:verticalAxis>

       

      <mx:series>

      <mx:LineSeries yField="close" xField="date" displayName="AAPL"/>

      </mx:series>

      </mx:LineChart>

       

      </mx:Panel>

      </s:Application>

      the above code shows reverse values of date on date axis i.e it should show 01/05 2/05 3/05 4/05 but its showing 10/05 09/05 08/05 07/05 on date axis.

      Please help.