0 Replies Latest reply on Jul 19, 2012 3:58 PM by tjnelso

    Maintaining X-Axis Values

    tjnelso Level 1

      I am trying to create a column chart from the following data with 'day' as the x-axis and 'sixes', 'sevens', and 'eights' as stacked series for the y-axis. Initially the data provider is 'arrayOne' but it then switches to 'arrayTwo' based on a timer. However, notice that in 'arrayOne' a value for day 3 is missing and in 'arrayTwo' a value for day 5 is missing. Right now, the x-axis gets redrawn to only fit days in the array acting as the dataProvider. I want the x-axis to remain constant when the data changes though. Is there any way I can make that happen?

       

      [CODE]
      [Bindable]
      private var arrayOne:ArrayCollection = new ArrayCollection([
             {time:1,day:5,sixes:10,sevens:15,eights:20},
             {time:1,day:4,sixes:12,sevens:13,eights:12},
             {time:1,day:2,sixes:15,sevens:10,eights:5},
             {time:1,day:1,sixes:15,sevens:10,eights:5},
            ]);
           
      [Bindable]
      protected var arrayTwo:ArrayCollection = new ArrayCollection([
             {time:2,day:4,sixes:30,sevens:35,eights:40},
             {time:2,day:3,sixes:25,sevens:10,eights:5},
             {time:2,day:2,sixes:30,sevens:35,eights:40},
             {time:2,day:1,sixes:25,sevens:10,eights:5},

            ]);


      //This function is called by the horizontal axis
      private function categoryLabelFunction(labelValue:Object, previousValue:Object, axis:IAxis):String
      {
            var index:int = int(labelValue);
            if(index >= 0 && index < nodesWipChart.dataProvider.length)
                  return nodesWipChart.dataProvider[index].day;
            return "";
      }

       

      //This is the portion of my code creating the horizontal axis
      <mx:horizontalAxis>
            <!-- This linear axis simulates a category axis to allow zooming -->
            <mx:LinearAxis id="daysOut"
                                   title="Days to Fab Out"
                                   labelFunction="categoryLabelFunction"
                                   interval="1"/>
      </mx:horizontalAxis>
      [/CODE]