3 Replies Latest reply on May 1, 2008 6:42 AM by theNOCer

    Help with DateTimeAxis

    azilaga
      I'm trying to create a chart with a DateTimeAxis, and I'd like the initial date to be pulled from a httpService, which I'll call "latest". The date is formatted as YYYY/DD/MM. With hardly any experience in AS or OOP languages, I can't figure out how to use the as the start date. Assume that I've initialized the service. Do I need to write a function to do this, and if so, what would that function look like. Then how should my dateTimeAxis block look like? Any help is appreciated. I'm getting a headache trying to figure this out.
        • 1. Re: Help with DateTimeAxis
          azilaga Level 1
          Managed to get started, but am at a loss on how to write my parseDate function. Below is the code I have so far and a snipped of the XML it's trying to read. Can someone help me get started on the parseDate function? Thanks!

          ======================== MXML ================
          <?xml version="1.0"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
          initialize="ThreeMo.send();">

          <mx:Script>
          <![CDATA[
          [Bindable]
          public var ffData:XMLList;

          public function parseDate(){
          //HELP HERE!

          }
          ]]>
          </mx:Script>

          <mx:HTTPService showBusyCursor="true"
          id="ThreeMo"
          url="fedfunds.xml"
          resultFormat="e4x" />

          <mx:Panel title="FF Chart" height="100%" width="100%">

          <mx:LineChart id="ff_chart"
          dataProvider="{ffData}" showDataTips="true"
          left="-2" top="67" height="343" width="585">

          <mx:horizontalAxis>
          <mx:DateTimeAxis dataUnits="days" parseFunction="parseDate"/>
          </mx:horizontalAxis>

          <mx:verticalAxis>
          <mx:LinearAxis baseAtZero="false" />
          </mx:verticalAxis>

          <mx:series>
          <mx:LineSeries id="lineFedFund" yField="value" displayName="Fed Funds"
          interpolateValues="true">
          <mx:lineStroke>
          <mx:Stroke weight="2" color="0xc58404" alpha="1" />
          </mx:lineStroke>
          </mx:LineSeries>
          </mx:series>
          </mx:LineChart>

          </mx:Panel>
          </mx:Application>


          ============XML==========
          <?xml version="1.0" encoding="UTF-8" ?>
          <data>
          <result>
          <title>US: 4.27 FedFunds 2008-01-07 NYFed daily fed funds effective rate</title>
          <link> http://www.newyorkfed.org/markets/omo/dmm/fedfundsdata.cfm</link>
          <description>daily federal funds effective rate for 2008-01-07 is 4.27</description>
          <date>1/7/2008</date>
          <fdate>2008-01</fdate>
          <high>7.00000</high>
          <low>4.12500</low>
          <target>4.25</target>
          <value>4.27</value>
          </result>
          <result>
          <title>US: 4.27 FedFunds 2008-01-08 NYFed daily fed funds effective rate</title>
          <link> http://www.newyorkfed.org/markets/omo/dmm/fedfundsdata.cfm</link>
          <description>daily federal funds effective rate for 2008-01-08 is 4.27</description>
          <date>1/8/2008</date>
          <fdate>2008-01</fdate>
          <high>4.56250</high>
          <low>4.00000</low>
          <target>4.25</target>
          <value>4.27</value>
          </result>
          <result>
          <title>US: 4.26 FedFunds 2008-01-09 NYFed daily fed funds effective rate</title>
          <link> http://www.newyorkfed.org/markets/omo/dmm/fedfundsdata.cfm</link>
          <description>daily federal funds effective rate for 2008-01-09 is 4.26</description>
          <date>1/9/2008</date>
          <fdate>2008-01</fdate>
          <high>4.50000</high>
          <low>4.13000</low>
          <target>4.25</target>
          <value>4.26</value>
          </result>
          </data>
          • 2. Re: Help with DateTimeAxis
            azilaga Level 1
            anyone?
            • 3. Re: Help with DateTimeAxis
              theNOCer
              well i dont know if your still having the problem but here is some help

              in the attached code is one of my parsers. that comes from the format YYYY-MM-DD hh:mm:SS.millies
              yours wont have to be as complicated but the idea is the same. take the string and cut it up and put it in a date obj.

              it also prints out the last timestamp broken down in a text box for error checking.