1 Reply Latest reply on Feb 22, 2008 11:02 AM by czflex

    Preventing repeat values on chart X axis

    azilaga Level 1
      Hi, I'm trying to modify a code I found to not repeat identical values on my chart's X-Axis, which is currently a date value. I have the date formatted as MMM-YYYY. Depending on the month range I'm displaying, I sometimes get repeating values like SEP-2007 SEP-2007 OCT-2007 NOV-2007 NOV-2007. Below is my attempt to modify the labelfunction, but it doesn't work. Any help would be appreciated. Thanks! BTW, I may be blind, but where is the "Attach Code" link on this New Topic page?


      private function categoryAxis_labelFunc(item:Object, prevValue:Object, axis:CategoryAxis, categoryItem:Object):String {
      var datNum:Number = Date.parse(item);
      var tempDate:Date = new Date(datNum);

      var returnThis:String = dateFormatter.format(tempDate).toUpperCase();
      var temp:String = '';

      if (returnThis !== temp) {
      temp = returnThis;
      return returnThis;
      }
      else {
      temp = '';
      return '';
      }
      }



      <mx:DateFormatter id="dateFormatter" formatString="MMM-YYYY" />

      <mx:horizontalAxis>
      <mx:CategoryAxis id="dateAxis"
      categoryField="date" title="Date"
      labelFunction="categoryAxis_labelFunc"
      />
      </mx:horizontalAxis>