/*Data Format: Decided upon on one common data store as makes intergrating pieChart, dataTable and barChart classes easier. The data is stored as follows (in a cross tabular format): chartData.rowLabels == an Array of strings of all row names chartData.colLabels == an Array of string of all col names chartData.tableColNames == an Array of strings of col names of non x-tab data chartData.cols == no. of cols for x-tab data chartData.rows == no. of rows for x-tab data chartData.colours == an Array of random colours to use for pieChart, barChart etc. chartData.row == an Array of rowObjects --> values == an Array of values for that row txt == an Array of strings of items (i.e contains acutal items/band names) name == string of the row name percs == an Array of percentage values (for xTab table) for that row angles == an Array of angles of percentages (for pie chart) for that row total == total of values for that row chartData.col == an Array of colObjects --> SAME AS ABOVE BUT FOR COLS NOT ROWS (Data repition but allows to edit data along both rows and cols: I can ask for the chartData.col[1].values and return all values for that col Likewise i can ask for chartData.row[1] and return all values for that row) */ import mx.data.components.*; //Import the components class so can refer to dataSet and XMLConnector components import Math2; //Import the math2 class class XTabData { static var chartData:Object = new Object(); //Static variable for storing the data static function getRandomData(items_ds:DataSet,items_xmlcon:XMLConnector) { //INIT OBJECT PROPERTIES var rows = 0; var cols = 0; var tableCols = 0; chartData.rowLabels = new Array(); chartData.colLabels = new Array(); chartData.tableColNames = new Array(); chartData.rows = 0; chartData.cols = 0; chartData.colours = new Array(); chartData.row = new Array(); chartData.col = new Array(); chartData.dataGridItems = new Array(); //LOAD ROW LABEL NAMES FROM XML for(var i in items_xmlcon.results.firstChild.firstChild.attributes){ //Loop through attributes in the xml object var temp = items_xmlcon.results.firstChild.firstChild.attributes; //Reference to all the attributes in the xml object chartData.rowLabels[chartData.rows] = eval("temp."+i); //Combine the xml object with the specific attribute name (i) and evaluate chartData.rows++; //Save the row label and update number of rows } //LOAD COL LABEL NAMES FROM XML - SAA but for columns for(var i in items_xmlcon.results.firstChild.childNodes[1].attributes){ var temp = items_xmlcon.results.firstChild.childNodes[1].attributes; chartData.colLabels[chartData.cols] = eval("temp."+i); chartData.cols++; } //LOAD NON X-TAB COL NAMES FROM XML - SAA but for non x-tab column names for(var i in items_xmlcon.results.firstChild.childNodes[2].attributes){ var temp = items_xmlcon.results.firstChild.childNodes[2].attributes; chartData.tableColNames[tableCols] = eval("temp."+i); tableCols++; } //For each row for (var i=0; i