{"size": 4066, "ext": "js", "max_stars_repo_path": "src/org.scn.community.databound/res/org.scn.community.databound.Base.js", "max_stars_repo_name": "Dibyendu21/Project", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/org.scn.community.databound/res/org.scn.community.databound.Base.js", "max_issues_repo_name": "Dibyendu21/Project", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/org.scn.community.databound/res/org.scn.community.databound.Base.js", "max_forks_repo_name": "Dibyendu21/Project", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 30.803030303, "max_line_length": 95, "alphanum_fraction": 0.621987211}
/**
 * Base Databound Class
 */
var org_scn_community_databound_Base = function(options){
	/**
	 * Flattens data from tuple format to 2D Array
	 * @author Mike Howles
	 * @param data { 
	 *	 	"selection" : [Array of dimension selections] 	
	 *	 	"tuples" : *Design Studio Tuples*,
	 *		"data" : *Design Studio Data*,
	 *   	"formattedData" : *Design Studio Formatted Data*,
	 * 		"dimensions" : *Design Studio Metadata Dimensions JSON*,
	 *		"locale" : *Design Studio user locale (e.g. en_US)",
	 *	  	"axis_columns : [Array of Column Axis Dimension Selection Members]
	 *	  	"axis_rows" : [Array of Row Axis Dimension Selection Members]
	 *	 }
	 * @param options {
	 * 		Placeholder
	 * }
	 * 
	 * @return {
	 * 		"columnHeaders" : [1D Array of Header Labels]
	 * 		"columnHeaders2D" : [2D Array of Header Labels]
	 * 		"rowHeaders" : [1D Array of Row Headers]
	 *  	"rowHeaders2D" : [2D Array of Row Headers]
	 * 		"values" : [2D Array of Measures] 
	 *
	 * }
	 */
	this.flattenData = function (data, options) {
		this.flatData = {
			columnHeaders : [],
			columnHeaders2D : [],
			rowHeaders : [],
			rowHeaders2D : [],
			values : [],
			formattedValues : [],
			hash : {}
		};
		if(!data || !data.dimensions || (!data.data && !data.formattedData)) {
			// throw("Incomplete data given.\n\n" + JSON.stringify(data));
			return this.flatData;
		}
		var dimensionCols = [];
		var dimensionRows = [];
		var data2D = [];
		var colLength = data.axis_columns.length;
		var rowLength = data.axis_rows.length;
		var tupleIndex = 0;
		// Make Row Header Labels
		for(var row=0;row<rowLength;row++){
			var newValueRow = [];
			var newFormattedValueRow = [];
			var rowHeader = "";
			var rowHeader2D = [];
			var rowAxisTuple = data.axis_rows[row];
			var sep = "";
			for(var j=0;j<rowAxisTuple.length;j++){
				if(rowAxisTuple[j] != -1){
					rowHeader += sep + data.dimensions[j].members[rowAxisTuple[j]].text;
					rowHeader2D.push(data.dimensions[j].members[rowAxisTuple[j]].text);
					sep = " ";
				}
			}
			this.flatData.hash[rowHeader] = row;
			this.flatData.rowHeaders.push(rowHeader);
			this.flatData.rowHeaders2D.push(rowHeader2D);
			for(var col=0;col<colLength;col++){
				if(data.data && data.data.length > 0){
					newValueRow.push(data.data[tupleIndex]);
				}
				if(data.formattedData && data.formattedData.length > 0){
					newFormattedValueRow.push(data.formattedData[tupleIndex]);
				}
				tupleIndex++;
			}
			if(newValueRow.length>0) this.flatData.values.push(newValueRow);
			if(newFormattedValueRow.length>0) this.flatData.formattedValues.push(newFormattedValueRow);
		}
		// Make Column Header Labels
		for(var col=0;col<colLength;col++){
			var colHeader = "";
			var colHeader2D = [];
			var colAxisTuple = data.axis_columns[col];
			var sep = "";
			for(var j=0;j<colAxisTuple.length;j++){
				if(colAxisTuple[j] != -1){
					colHeader += sep + data.dimensions[j].members[colAxisTuple[j]].text;
					colHeader2D.push(data.dimensions[j].members[colAxisTuple[j]].text);
					sep = " ";
				}
			}
			this.flatData.columnHeaders.push(colHeader);
			this.flatData.columnHeaders2D.push(colHeader2D);
		}
		return this.flatData;
	};
	var that = this;
	this.props = {
		data : { 
			value : null,
			onChange : this.flattenData
		}
	};
	this.flatData = null;
	for(property in options){
		this.props[property] = options[property]
	};
	/*
	 * Create the aforementioned getter/setter and attach to 'this'.
	 */
	for(var property in this.props){
		this[property] = function(property){
			return function(value){
				if(value===undefined){
					return this.props[property].value;
				}else{
					this.props[property].value = value;
					this.props[property].changed = true;
					if(this.props[property].onChange) {
						this.props[property].onChange.call(this,this.props[property].value);
					}
					return this;
				}
			};
		}(property);
	}
	this.init = function(){
		this.$().addClass("DesignStudioSCN");
	}
};