Created
October 2, 2015 16:36
-
-
Save leongaban/ea9b93c31c9a88717299 to your computer and use it in GitHub Desktop.
formatData
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// If tags, GET tag volume data: | |
if (tags.length > 0) { | |
console.log('tags.length: ',tags.length); | |
for (var i=0; i<tags.length; i++) { | |
var loopStep = i; | |
rawTagData = []; | |
GetTweetVolFactory.returnTweetVol(tags[i].term_id, limit_range) | |
.success(function(data, status, headers, config) { | |
rawTagData.push(data.frequency_counts); | |
if (loopStep === (rawTagData.length - 1)) { | |
formatTagData(rawTagData); | |
} | |
}).error(function(data, status) { | |
console.log('error in returning tweet data'); | |
console.log(data); | |
return 'error in returning tweet data'; | |
}); | |
} | |
chartTags = true; | |
} | |
else { | |
chartTags = false; | |
getTickerPrice(); | |
} | |
function formatTagData(rawData) { | |
for (var i=0; i<rawData.length; i++) { | |
var loopStep = i; | |
var data_array = {}; | |
data_array.loopStep = new Array(); | |
// tweetArrayObjsContainer = []; // <- uncommented this and tweetArrayObjsContainer will always have 1 | |
for (var j=0; j<rawData[i].length; j++) { | |
rawData[i].start_epoch = addZeroes(rawData[i].start_epoch); | |
data_array.loopStep.push([rawData[i].start_epoch, rawData[i].tweets]); | |
} | |
// // Reverse the array: | |
_(data_array.loopStep).reverse().value(); | |
var tweetArrayObj = { | |
"Name" : loopStep, | |
"key" : "Quantity", | |
"bar" : true, | |
"color" : '', | |
"color" : tagColorArray[loopStep], | |
"values" : data_array.loopStep | |
}; | |
tweetArrayObjsContainer.push(tweetArrayObj); | |
console.log('tweetArrayObjsContainer = ',tweetArrayObjsContainer); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment