0 Replies Latest reply on Jul 31, 2012 12:44 PM by tjnelso

    Can't Use Chart If Not In All States?

    tjnelso

      I am trying to create a component that has 4 view states that contain the following:

       

      state1: Displays only chart 1

      state2: Displays only chart 2

      state3: Displays chart 1 and chart 2

      state4: Displays neither chart

       

      Both of these charts have series that are populated dynamically using a call the my 'updateChartSeries(string:String)' method. However, if I specify that chart 1 is only to be included in states 1 and 3, I get an error from in the 'updateChartSeries' method, even if I do something like:

       

      [code]

       

      public function updateChartSeries(series:String):void

      {

           if(currentState == "state1")

           {

                 var chartSeries:Array = new Array;

       

                var demand:columnSeries = new ColumnSeries();

                demand.id = series;

                demand.dataFunction = dataFunc;

       

                var gap:LineSeries = new LineSeries();

                gap.id = series;

                gap.dataFunction = dataFunc;

       

                chartSeries.push(demand);

                chartSeries.push(gap);

       

                chart1.series = chartSeries;

           }

      }

      [/code]

       

      This code works fine for populating the chart data unless I exclude chart1 from any of the view states. Then it starts giving me an error at 'chart1.series = chartSeries'. How can this be fixed?