2 Replies Latest reply on Feb 26, 2010 1:13 PM by aurphir

    In flex charts the label for next month get dropped

    aurphir

      I found for DatatTimeAxis if you set disabledRanges to the last date of the month the label for next month gets dropped using property labelUnits='months". Any ideas? Below is the code:

       

      <?xml version="1.0"?>
      <!-- Simple example to demonstrate the DateTimeAxis class. -->
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
      
           <mx:Script>
                <![CDATA[
                     import mx.collections.ArrayCollection;
      
                     [Bindable]
                     public var stockDataAC:ArrayCollection=new ArrayCollection([{date: "2005, 6, 1",
                               close: 30}, {date: "2005, 7, 31", close: 25}, {date: "2005, 8, 3",
                               close: 40}, {date: "2005, 9, 4", close: 30}, {date: "2005, 10, 5",
                               close: 50}, {date: "2005, 11, 6", close: 43}]);
                     private var d:Date=new Date("7/31/2005");
                     [Bindable]
                     private var offDays:Array=[d];
      
                     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 because months are zero-based in 
                          // the Date constructor.
                          var newDate:Date=new Date(a[0], a[1] - 1, a[2]);
                          return newDate;
                     }
                ]]>
           </mx: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"
                                               disabledRanges="{offDays}"
                                               labelUnits="months"/>
                     </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>
      </mx:Application>
      

        • 1. Re: In flex charts the label for next month get dropped
          Gregory Lafrance Level 6

          I found your posted code to be messed up. I fixed it and could not see your problem.

           

          Here is the fixed code.

           

          <?xml version="1.0"?>
          <!-- Simple example to demonstrate the DateTimeAxis class. -->
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
               <mx:Script>
                    <![CDATA[
                         import mx.collections.ArrayCollection;
                         [Bindable]
                         public var stockDataAC:ArrayCollection=new ArrayCollection([
                           {date: "2005, 6, 1", close: 30}, 
                           {date: "2005, 7, 31", close: 25}, 
                           {date: "2005, 8, 3", close: 40}, 
                           {date: "2005, 9, 4", close: 30}, 
                           {date: "2005, 10, 5", close: 50}, 
                           {date: "2005, 11, 6", close: 43}]);
                         private var d:Date=new Date(2005,8,31);
                         [Bindable]
                         private var offDays:Array=[d];
                         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 because months are zero-based in 
                              // the Date constructor.
                              var newDate:Date=new Date(a[0], a[1] - 1, a[2]);
                              return newDate;
                         }
                    ]]>
               </mx: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"
                                                   disabledRanges="{offDays}"
                                                   labelUnits="months"/>
                         </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>
          </mx:Application>
          
          


          If this post answers your question or helps, please mark it as such.


          Greg Lafrance - Flex 2 and 3 ACE certified

          www.ChikaraDev.com

          Flex / AIR Development, Training, and Support Services

          • 2. Re: In flex charts the label for next month get dropped
            aurphir Level 1
            private var d:Date=new Date(2005,8,31)
            

             

            Above code doesn't declare a valid date