0 Replies Latest reply on Jan 29, 2013 4:01 PM by AllynTech

    Flex 3 Adding LineSeries via ActionScript


      I have seen a few posts on this, and I have had my current code working, but when it doesn't work I find myself at a loss to be able to debug why.


      My SensorReading object:


      public class SensorReading


           public var SensorName:String;

            public var ChannelName:String;

           public var UOM:String;

           public var ReadingDate:Date;

           public var ReadingValue:String;



      I can dynamically get up to 32 different channels of information. Each channel of data is an array of SensorReadings, and I receive an ArrayCollection of all the readings arrays (e.g. dataCollection.getItemAt(5) would receive the data array for channel #6's data).


      All I get is blank charts (code below). I have set breakpoints on many locations, including creating debug functions for series.dataFunction and chart.click(), and the series all seem to be correct, and the dataProviders for each line appears to be correct.


      Any thoughts on the issue would be greatly appreciated!



      //view.chart is the LineChart target

      // clear out any existing chart axis

      var seriesArray:Array = new Array();

      view.chart.series = seriesArray;

      view.chart.verticalAxis = new LinearAxis();



      // prepare for multiple axes if needed

      var axisIndex:Array = new Array();

      var axis:LinearAxis;

      var axisRenderer:AxisRenderer;

      var axisRenderers:Array = new Array();



      // channel data collection

      for ( var j:int = 0; j < channelDataColl.length; j++ )


                // get the first row of data to set up

                // the series information from

                reading = ( channelDataColl.getItemAt(j) as Array )[0] as SensorReading;


                // instance a new lineseries for this dataset

                var series:LineSeries = new LineSeries();


                var channelProvider:Array = channelDataColl.getItemAt(j) as Array;

                series.dataProvider = channelProvider;

                series.yField = "ReadingNumber";

                series.xField = "ReadingDate";

                series.displayName = reading.SensorName + "\n" +

                          reading.ChannelName + "\n" +



                // if we have a new unit of measure, then

                // add a new vertical axis unless this is

                // the first one

                if ( axisIndex.indexOf( reading.UOM ) < 0 )


                          axis = new LinearAxis();

                          axis.displayName = reading.UOM;

                          axis.title = reading.UOM;

                          axis.autoAdjust = true;


                          // check if this is the first axis

                          if ( axisIndex.length == 0 )


                                    // work around a flex issue by using

                                    // the default axis for the first axis

                                    view.chart.verticalAxis = axis;




                                    series.verticalAxis = axis;

                                    axisRenderer = new AxisRenderer();

                                    axisRenderer.axis = axis;


                                    axisRenderers.push( axisRenderer );

                                    view.chart.verticalAxisRenderers = axisRenderers;



                          // add uom to our existing list

                          axisIndex.push( reading.UOM );



                // add this series to the chart

                var seriesArray:Array = view.chart.series;

                seriesArray.push( series );

                view.chart.series = seriesArray;



      // end of code



      // MXML


                id="chart" width="100%" height="100%"



                click="onChartDebugClick( event )"














                          <mx:AxisRenderer axis="{hAxis}"