I am trying to create a column chart that reads in data from an embedded .csv file and transforms the data to the following array stucture:

Code:
[Bindable]
private var arrayOne:ArrayCollection = new ArrayCollection([
         {time:1,day:3,typeA:{wip:10,proj:15},typeB:{wip:15,proj:9},typeC:{wip: 20,proj:20}},
         {time:1,day:2,typeA:{wip:12,proj:14},typeB:{wip:13,proj:12},typeC:{wip :12,proj:17}},
         {time:1,day:1,typeA:{wip:15,proj:14},typeB:{wip:12,proj:10},typeC:{wip :5,proj:9}}
]);
BUT, the .csv file will refresh every so often to display new data so the array could change. The only thing I know for sure is that there will be a time and day value. TypeA, TypeB, and TypeC are product types, and they might or might not be in my dataset, simply depending on the result of a SQL query. So I need to be able to create chart series for typeA, typeB, and/or typeC (or any other type that I may not even know about yet) given that they appear in my dataset.

If I want to display 'wip' values on the y-axis and 'day' values on the x-axis than I know I need to use dataFunction because my associative arrays contain keys that refer to objects, and I actually need to access the nested 'wip' property for any given product type.

So the method below takes in an array as a parameter that contains the name of each part type that shows up in my data array. By passing it into this function I create a column series for every part type. I also specify that the dataProvider for each series is the 'dataFunc' function.

Code:
protected function init(event:FlexEvent):void
{
	allSeries.addItem("typeA");
	allSeries.addItem("typeB");
	allSeries.addItem("typeC");
	updateChartSeries(allSeries);
}


//----------------------------------------------------------------------------------
public function updateChartSeries(seriesArray:ArrayCollection):void
{
	var mySeries:Array = new Array();
					
	for(var i:int = 0; i < seriesArray.length; i++)
	{
		var legend:String = seriesArray[i].toString() + " Series";
						
		trace(seriesArray[i].toString());
						
		var col:ColumnSeries = new ColumnSeries()
		col.id = seriesArray[i].toString();
		col.displayName = legend;
		col.filterData = false;						col.dataFunction = dataFunc;
						
		mySeries.push(col);
	}
					
	Chart.series = mySeries;
}
Once all the series have been created the dataFunction is called (I've named my dataFunction 'dataFunc'). In tracing through dataFunc it seems that the function iterates through each series that I created (so in this example it will iterate through typeA, typeB, and typeC, and for each series it passes in each item of the dataProvider and either the 'xValue' or 'yValue'.

I don't totally understand how to utilize this function though. If I want the 'typeA' series to be populated with typeA[wip] values, should my code be something like the following:

Code:
//----------------------------------------------------------------------------------
private function dataFunc(series:Series, item:Object, fieldName:String):object 
{ 
             //Iterates through all properties of my data objects (time, day, sixes, sevens, eights)
	for(var part:Object in item)
	{
		if(fieldName == "yValue" && series.id == part.toString())
			return(item[part].wip);	
		else if(fieldName == "xValue")
			return (item.day);	
		else
			return null;
	}
	return "";
}
To me the 'dataFunc' code above seems right but it's really not coming out as I expect it to. I also don't understand the the 'fieldName' parameter? Why does the function pass in 'xValue' and 'yValue' for each iteration? How can I fix this code to get the data displaying as I want it to?