#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    29
    Rep Power
    0

    JSON collect data


    http://pastebin.com/FPAQ1KzX


    Hi to all, as you can see in the code above, i have a JSON code and have to save dinamicly data for th all years.
    Code:
    for (var i = 0; i < dataAllYear.length; i++ ){
    		//collect names 
    		namesFirstYear = dataAllYear[i].Language;
    		collectNames.push(namesFirstYear);
    		//data for first year 
    		speakers = dataAllYear[i][ years ];
    I have this for now, but its not what i need. Tell me how to collect for each name data, because after i collect it i have to draw him.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    29
    Rep Power
    0
    Code:
    for (var j = 1; j < columns.length; j++){
    			years.push(columns[j]['name']);
    			objSpeakers[columns[j]['name']] = {"set":[],"seriesName":columns[j]['name']};
    		}
    		for (var i = 0; i < dataAllYear.length; i++ ){
    			namesFirstYear = dataAllYear[i].Language;
    			collectNames.push(namesFirstYear);
    			for (var k in years){ 
    				speakers = dataAllYear[i][ years[k] ];
    			//speakersSet = {"color":"AFD8F8","set":[]};
    				objSpeakers[years[k]].set.push({value:speakers,color:'fff000'}); 
    			}
    			dataDir.categories.category.push({label:namesFirstYear});	
    		}
    		for (var k in years){
    			dataDir.data.push(objSpeakers[years[k]]);
    		}
    	createSecondChart(collectNames,dataDir);
    This is what i have done, but it have too many for loops, how can i eliminate him.

IMN logo majestic logo threadwatch logo seochat tools logo