6 Replies Latest reply on Nov 13, 2008 5:12 AM by Cr99

    generic labelfunction

    Cr99 Level 1
      I have a labelfunction for charts that displays labels in the following format:

      Oct/21
      2008
      12:00

      Now the data for my charts sometimes has a range of seconds, sometimes months, sometimes years, etc. So I'd like to have ranges which span months leave off the time for instance, while those with ranges in the seconds don't really need the year displayed. But you can't pass anything into the label function to indicate this (say a Boolean variable or something). Here is my function in its current form:


        • 1. Re: generic labelfunction
          Level 7

          "Cr99" <webforumsuser@macromedia.com> wrote in message
          news:gff1dg$prv$1@forums.macromedia.com...
          >I have a labelfunction for charts that displays labels in the following
          >format:
          >
          > Oct/21
          > 2008
          > 12:00
          >
          > Now the data for my charts sometimes has a range of seconds, sometimes
          > months,
          > sometimes years, etc. So I'd like to have ranges which span months leave
          > off
          > the time for instance, while those with ranges in the seconds don't really
          > need
          > the year displayed. But you can't pass anything into the label function
          > to
          > indicate this (say a Boolean variable or something). Here is my function
          > in
          > its current form:
          >
          >
          >
          >
          > private function fullTimeLabelFunction(labelValue:Object,
          > previousValue:Object, axis:DateTimeAxis):String {
          > var a:Array = labelValue.toString().split(" ");
          > var yr:String = a[5].toString().substr(2,3);
          > var day:String = a[2].toString();
          > var result:String = " "+a[1]+"/"+a[2]+"\n "+a[5]+"\n"+a[3];
          > return result;
          > }

          Is there some other value that you could look at, for instance a property of
          the chart the axis is part of?


          • 2. Re: generic labelfunction
            bzvine
            What is in the previousValue.Object - doe it relate to the last date for this chart?
            • 3. Re: generic labelfunction
              bzvine Level 1
              If the previousValue relates to the previous chart of the same type you may want to split it and create two dates then determine time between the dates:
              var cDate:Date = new Date(year, month, day, hour, seconds) ;
              var pDate:Date = new Date(pYear, pMonth, pDay, pHour, pSeconds) ;

              now your logic will be based on the difference in milliseconds between the two date instances.

              Hope this helps.
              Dick
              • 4. Re: generic labelfunction
                Cr99 Level 1
                Thanks for the reply. The previousLabel idea seemed promising, except I don't know what to do about the first time the function gets called since previousLabel will be null. The following code works correctly for every case except the first:


                • 5. Re: generic labelfunction
                  ntsiii Level 3
                  Maybe an "else" clause on the conditional?
                  Tracy
                  • 6. generic labelfunction
                    Cr99 Level 1
                    Thanks again for all the help. I think I've got it now. There is indeed a way to pass this information through the axis object using labelunits. Of course you have to set labelUnits on the axis for this to work. Here's the way I ended up doing it: