0 Replies Latest reply on Jul 21, 2012 9:54 PM by tjnelso

    Need Help Understanding dataFunction

    tjnelso Level 1

      I'm confused as to how the dataFunction method works. Namely, I don't understand how to call the dataFunction. Here is my chart data, in the array named 'arrayOne'. I want the x-axis to populate with the 'day' items and I want stacked columns where each stacked column is the 'wip' item in a 'type' property. This would allow me to see the amount of wip corresponding to each part type on every day.


      [Bindable] private var arrayOne:ArrayCollection = new ArrayCollection([



                     {time:1,day:1,typeA:{wip:15,proj:14},typeB:{wip:12,proj:10},typeC:{wip:5,proj:9}}, ]);


      In my init() function I have an arrayCollection called 'allSeries' that I'm using to create checkboxes for each part type. Since this array contains a list of all part types I would also like to use it to make a chart series for every element in the array. So I have a call to a function called 'updateChartSeries' that is defined to populate my column chart series with the elements of 'allSeries'.


      protected function init():void


           allSeries.addItem("TypeA");      //This is an array collection holding the series names






      The 'updateChartSeries' function is below. It takes an arrayCollection as a parameter, such as 'allSeries', and is suppose to create a column series for each element of the passed in arrayCollection. To do this it needs to recognize the part type name from my dataprovider table ('arrayOne') and assign the corresponding wip value as the column series yField. That's what I can't figure out how to do.


      public function updateChartSeries(seriesArray:ArrayCollection):void


           var mySeries:Array = new Array(); 


           for(var i:int = 0; i < seriesArray.length; i++)


                var legend:String = "part " + seriesArray[i].toString(); 


                var col:ColumnSeries = new ColumnSeries();

                col.id = seriesArray[i].toString();

                col.displayName = legend;

                col.filterData = false;

                col.dataFunction = Function(dataFunc(col, seriesArray[i]));    //I don't know how to call the function here. 





           typeChart.series = mySeries;



      private function dataFunc(series:Series, item:Object, fieldName:String):object


           //I don't know what to put here! I think I want to return item.(seriesArray[i]).wip;